htaccess的重定向循环!所有子目录的根 [英] .htaccess redirect loop! All subdirectories to root

查看:133
本文介绍了htaccess的重定向循环!所有子目录的根的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过的.htaccess重定向所有子目录到我的网站的根! 下面的code工作正常,如果我试图访问一个子目录...但不会让我显示根索引页,因为启动重定向的循环!

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 the index page in the root because starts a loop of redirects!

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

我该如何解决这个问题?

How can I solve this?

推荐答案

如果您希望所有subdirectores重定向到主页,你会做这样的事情:

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

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

这将匹配任何URI在这两条斜线,跟他们之间至少有一个字符。

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

这篇关于htaccess的重定向循环!所有子目录的根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆