Search code examples
javascriptajax.htaccesshttp-status-code-301

internaly linking to home page (/index) using ajax when htacess redirects home page to mydomain.com


I am using a redirect in my Apache .htaccess file to send all traffic from index.html to mydomain.com. To do this, I am using the following:

Options +FollowSymLinks
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://www.mydomain.com/$1 [R=301,L]

What I'm having trouble with now is using a relative path to my home page when calling content in to a <div> using AJAX.

If I want to get content from /index.html, I get a 404 error. I can over come this by using an absolute path ie. "http://mydomain.com", but is there a way I can still use the relative path to the homepage?


Solution

  • Just off the top of my head, I'd say your URL parameters/anchor isn't going through the rewrite. You can fix that with the QueryStringAppend QSA flag like so:

    RewriteRule ^(.*)index.html$ http://www.mydomain.com/$1 [QSA,R=301,L]