apache - How do I htaccess redirect index.html to index.php and index.php to / -
i changed index.html index.php - want able redirect reflect this, , rewrite forces foo.com/index.php foo.com/ , have access .php file.
i have separate site i.e. bar.com located in subdirectory under foo.com want remain unaffected.
this had, results in redirect loop:
redirectmatch 301 ^/index.html?$ /index.php options +followsymlinks rewriteengine on rewritecond %{the_request} ^[a-z]{3,9}\ /.*index\.php\ http/ rewriterule ^(.*)index\.php$ /$1 [r=301,l]
is there way this? thanks!
the redirectmatch
directive matches after internal redirect takes /
request , redirects /index.html
, put through url-file mapping pipeline again , matches redirect directive.
you can try including a:
directoryindex index.php
to prevent automatic internal redirect. should use %{the_request}
match index.html
file you're doing index.php
:
options +followsymlinks directoryindex index.php rewriteengine on rewritecond %{the_request} ^[a-z]{3,9}\ /.*index\.php\ http/ rewriterule ^(.*)index\.php$ /$1 [r=301,l] rewritecond %{the_request} ^[a-z]{3,9}\ /.*index\.html\ http/ rewriterule ^(.*)index\.html$ /$1index.php [r=301,l]
or can bypass index.php entirely:
rewritecond %{the_request} ^[a-z]{3,9}\ /.*index\.html\ http/ rewriterule ^(.*)index\.html$ /$1 [r=301,l]
Comments
Post a Comment