问题
Hey guys I'm not sure how to phrase this to get the correct search, so here goes i would like to redirect all queries for /directory/index.html to /directory/ which is (really) /directory/index.php I wrote this out but it inserts my entire web root structure (/var/www/html/directory/index.php) so it's a no go, maybe someone could help me a bit? Does this make sense?
here's the code
RewriteEngine On
RewriteRule ^index.(htm|html?)$ ^index.php [R=301,L]
EDIT
I solved it with this, but I'm sure theres a better way?
RewriteEngine On
RewriteRule ^index.(htm|html?)$ %{REQUEST_URI}/../index.php [R=301,L]
回答1:
This might work (and is cleaner, I think):
RewriteEngine On
RewriteRule ^index\.(htm|html?)$ /index.php [QSA,NC,R=301,L]
来源:https://stackoverflow.com/questions/8609119/redirecting-directory-index-html-to-directory