1

我想将所有页面重定向到带有路径的维护站点

/software/web/app.php/update

所以我需要重定向所有页面,除了网站本身,否则我会得到一个重定向循环,这意味着我需要一个匹配该路径并否定它的规则。听起来很简单,但对我不起作用。

RedirectMatch (?!/software/web/app.php/update) h*tp://abc.de/software/web/app.php/update

重定向匹配 ^(?!/software/web/app.php/update)$ h*tp://abc.de/software/web/app.php/update

RedirectMatch ^/software/web/app.php(?!/update)$ h*tp://abc.de/software/web/app.php/update

这些都没有帮助。我尝试了在这里和其他网站上找到的几乎所有东西,但经过数小时的试用,我投降并恳请您的帮助。先感谢您。

4

1 回答 1

-1

You could do this with just a simple RewriteRule prefixed with a condition:

RewriteEngine on
RewriteCond %{REQUEST_URI} !(^/software/web/app.php/update$)
RewriteRule .* /software/web/app.php/update [R=307]

If the maintenance site contains things like images then you will need to exclude those images from the rule, for example:

RewriteEngine on
RewriteCond %{REQUEST_URI} !(^/images/maintaining.jpg$)
RewriteCond %{REQUEST_URI} !(^/software/web/app.php/update$)
RewriteRule .* /software/web/app.php/update [R=307]

If you are redirecting to another site, then the rule can be used to put the entire URL:

RewriteRule .* http://example.com/software/web/app.php/update [R=307]

For reference, the [R=307] at the end of the RewriteRule states that the browser would see the URL rewritten, but that it is a temporary redirect.

于 2013-06-20T11:18:01.067 回答