开发者

.htaccess redirect loop! All subdirectories to root

开发者 https://www.devze.com 2022-12-09 19:36 出处:网络
I\'m trying to redirect all subdirectories to the root of my website via .htaccess! The code below works fine if I try to access a subdirectory ... but doesn\'t let me display t开发者_StackOverflow中文

I'm trying to redirect all subdirectories to the root of my website via .htaccess! The code below works fine if I try to access a subdirectory ... but doesn't let me display t开发者_StackOverflow中文版he index page in the root because starts a loop of redirects!

RedirectMatch temp ^/.*$ http://localhost/

How can I solve this?


If you want all subdirectores to redirect to the home page, you would do something like this:

RedirectMatch temp ^/.+/.*$ http://localhost/

This will match any URI with two slashes in it, with at least one character between them.

0

精彩评论

暂无评论...
验证码 换一张
取 消