I have a .htaccess file:
RewriteEngine On
DirectoryIndex control.php
Options +FollowSymlinks
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.+) controller.php?do=$1 [L]
This redirects all queries and sets up clean URLs. But when I use ajax it redirects that too. Is it possible to filter ajax queries and redirect to
controller-ajax.php?do=$1 [L]
instead?
I was trying to catch it in controller.php, but X_REQUESTED_WITH doesn’t exist. The best thing then would be to redirect to another script all ajax requests, and not make an additional script check.
When you call AJAX, add a GET variable to the query (i.e. add
?ajax=trueto the end of the query). Then have this in your .htaccess: