【发布时间】:2017-03-26 11:51:38
【问题描述】:
我在尝试为生产/实时环境设置多个 RewriteBase 目录时遇到问题。我已按照以下网址提供的指导进行操作:
Many RewriteBase in one .htaccess file?
With mod_rewrite can I specify a RewriteBase within a RewriteCond?
这似乎可以广泛使用,除非基本目录是根目录(即“/”),如下所示:
RewriteCond %{HTTP_HOST} ^localhost/tla-test/(.)$ [OR]
RewriteCond %{HTTP_HOST} ^192.168.0.200/tla-test/(.)$
RewriteRule ^(.*)$ tla-test/index.php&page=$1 [L]
RewriteCond %{HTTP_HOST} ^test.townshendla.com/(.)$
RewriteRule ^(.*)$ /index.php&page=$1 [L]
#Send any reqests to the index.php file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php
第一个重写条件完美运行。第二个重写条件在启动时不断出现错误 500。因为它是 1and1,所以我无法获取 Apache 错误日志,但如果我尝试在测试环境中复制,我会收到以下错误(请注意这可能无关):
AH00124:请求超出了 10 个内部重定向的限制,原因是 可能的配置错误。使用“LimitInternalRecursion”增加 必要时限制。使用“LogLevel debug”获取回溯。
任何想法将不胜感激。
【问题讨论】:
-
HTTP_HOST只匹配主机名而不匹配 URI -
你正在重写你重写的 URL。先了解mod rewrite rules are applied more than once.
标签: apache .htaccess mod-rewrite