Hi guys,
I've been tinkering with URL Rewriting on my site and fixing the canonicalization of my URLs (so I don't have duplicate data on search engines, etc.) and it was recommended everywhere to either always remove/force the trailing slash (I chose to remove it) and also to redirect /index to . So I put the following two rules in my .htaccess for Apache's mod_rewrite to pick up:
--remove trailing slash
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
--remove trailing /index
RewriteRule ^(.*)/?index$ http://%{HTTP_HOST}/$1 [R=301,L]
These rules work just fine in the browser. But some of my ajax forms stopped functioning all of a sudden! I traced it both in Chrome and Firefox(Firebug) and what happens is very strange. In both browsers, the page does an ajax call to:
<mydomain>/ajax/index (ajax params intact) --> 301 redirect to <mydomain>/ajax/
<mydomain>/ajax/ (ajax params are no longer sent!) --> 301 redirect to <mydomain>/ajax
<mydomain>/ajax (ajax params again not sent) --> 200 OK but obviously script complains that params don't exist
Can anyone confirm that this is the case or am I losing it? If so, why the heck does it behave like this? And is there a proper solution for fixing it (other than changing all my ajax calls to never get redirected eg <mydomain>/ajax
)?
Thank you very much for you time guys :)
Cheers
Ali