mod_rewrite 直接子域访问
我们正在设置一个 API,我们希望使用 Apache mod_rewrite 将所有访问定向到 http://api.domain.com< /a> 到位于 /cgi-bin/api.pl 的脚本。这是我们当前正在使用的:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^api.domain.com$ [NC]
RewriteRule ^(.*)$ /cgi-bin/api.pl [NC,L,QSA]
但是,这给我们带来了以下错误:
[Fri Sep 03 14:18:32 2010] [error] [client 67.180.34.0] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary.
[Fri Sep 03 14:18:32 2010] [error] [client 67.180.34.0] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
如果我们尝试访问 http://domain.com/cgi-bin/api.pl 脚本正常运行。我们做错了什么?请帮忙!提前致谢。
We are setting up an API and we want to use Apache mod_rewrite to direct all accesses to http://api.domain.com to the script located at /cgi-bin/api.pl. Here is what we're currently using:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^api.domain.com$ [NC]
RewriteRule ^(.*)$ /cgi-bin/api.pl [NC,L,QSA]
However, this is giving us the following error:
[Fri Sep 03 14:18:32 2010] [error] [client 67.180.34.0] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary.
[Fri Sep 03 14:18:32 2010] [error] [client 67.180.34.0] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
If we try to access http://domain.com/cgi-bin/api.pl the script functions properly. What are we doing wrong? Please help! Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您在
.htaccess
文件中定义规则,其中L
标志 可能不会像您预期的那样工作。由于您的测试模式
^(.*)$
与提供给它的任何输入相匹配,因此您重写的 URL 也会在后续请求中匹配,并且您会得到一个内部无限重定向循环(最终导致服务器错误)。解决方案是检查您是否已经重写了 URL:
I assume that you're defining your rules in a
.htaccess
file, where theL
flag might not work like you were expecting.Since your test pattern
^(.*)$
matches whatever input is given to it, the URL you rewrite to is also matched on the subsequent request, and you get an internal infinite redirection loop (resulting eventually in the server error).A solution is to check to see if you've already rewritten the URL: