mod_rewrite 所有内容到一个登陆页面
我需要关闭整个网站,因此我想将所有请求路由到登陆页面。 mod_rewrite 是什么样的?我的指令在 Firefox 中给了我一个“永远无法完成”的错误。
RewriteEngine on
RewriteCond %{REQUEST_URI} !^[^.]*/$
RewriteRule ^(.*)$ /alert.php [R=301,L]
I need to take down an entire site, so I want to route everything request to a landing page. What does the mod_rewrite look like for that? My directives are giving me a "can never complete" error in firefox.
RewriteEngine on
RewriteCond %{REQUEST_URI} !^[^.]*/$
RewriteRule ^(.*)$ /alert.php [R=301,L]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您重定向到的页面与重写模式匹配,因此当浏览器由于 301 重定向而尝试请求该页面时,它会再次重定向(导致无限循环,Firefox 足够聪明,可以注意到这一点)。您需要在规则中添加例外以避免这种情况:
The page you're redirecting to matches the rewrite pattern, so when the browser tries to request it as a result of the 301 redirect, it gets redirected again (causing an infinite loop, which Firefox is smart enough to notice). You'll want to add an exception to your rule to avoid this: