0

I have this rewrite

RewriteCond %{HTTP:x-requested-with} ^XMLHttpRequest$
RewriteRule ^(messages.*) /other/$1 [R=301,NC,L]

I want to redirect all AJAX/XMLHttpRequest requests from /messages to /other/messages

The condition and rule above works for /messages but not messages/1.json

Can anyone point me to what is wrong with my rewrite?

Thank you in advance!

  • 2
    The `rewrite;rule` looks fine to me. You'll need to enable logging of mod_rewrite to debug, details here: http://wiki.apache.org/httpd/RewriteLog There are a number of reasons why it might happen, the logging should show us. Add the output to your question – Unbeliever Oct 03 '16 at 11:25
  • As Unbeliever has just mentioned, it should already work for URLs of the form `/messages/1.json`. However, this should probably be an _internal rewrite_, not an external redirect? Your AJAX request must otherwise follow the redirect and make a second request. (?) – MrWhite Oct 03 '16 at 11:27

0 Answers0