开发者

mod_rewrite everything to one landing page

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
Rewrite开发者_运维百科Cond %{REQUEST_URI} !^[^.]*/$
RewriteRule ^(.*)$ /alert.php [R=301,L]


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:

# the conditions are implicitly combined
# with a logical AND
RewriteCond %{REQUEST_URI} !=/alert.php
RewriteCond %{REQUEST_URI} !^[^.]*/$
RewriteRule ^(.*)$ /alert.php [R=301,L]
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜