Redirecting /directory/index.html to /directory/

狂风中的少年 提交于 2019-12-12 05:49:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!