【发布时间】:2012-04-06 12:45:18
【问题描述】:
我想这样重定向...
http://old.com/a/b/ -> http://new.com/y/z/
http://old.com/a/b/file.php -> http://new.com/y/z/
http://old.com/a/b/c/file.php -> http://new.com/y/z/
http://old.com/a/b/anything -> http://new.com/y/z/
http://old.com/a/b/EXCLUDE.php -> http://old.com/a/b/EXCLUDE.php
我目前在 httpd.conf 中有以下内容,并且重定向正确:
RedirectMatch 301 /a/b/(.*) http://new.com/y/z/
我不知道如何排除一个文件被重定向。
基本上,我希望所有以“old.com/a/b/”开头的 URL 都转到一个新的 URL,但我希望忽略一个 URL。
【问题讨论】:
-
根据httpd.apache.org/docs/2.0/mod/mod_alias.html,你不需要 (.*); RedirectMatch 替换了 URL 的开头,因此 /a/b/ 下的所有内容无论如何都会被捕获。至于您的问题,如何在现有规则之前添加“RedirectMatch 301 /a/b/EXCLUDE.php /a/b/EXCLUDE.php”?我不知道它是否会起作用,但值得一试。
标签: apache .htaccess mod-rewrite httpd.conf