【问题标题】:Mod-rewrite causing infinite loop on subdomains?Mod-rewrite导致子域无限循环?
【发布时间】:2011-07-13 07:09:09
【问题描述】:

在我的新网站上,我想拥有动态子域。我正在尝试使子域使用与主域相同的 Web 根目录,所有这些都在单个 CodeIgniter 安装下。比如subdomain.example.com会导致example.com/subdomain,其实就是example.com/index.php/subdomain。

我已经设置了 DNS,但我正在关注.htaccess

VirtualDocumentRoot /var/www/crashworks/public/%-3+ 是我的站点可用配置中的行,只是为了完整性。这也可能是问题的根源。

链接 htaccess 的效果是,当导航到任何子域时,它会陷入无限循环。 (Error log after one request.) www. 也是一样的效果,应该只解析到主域。

【问题讨论】:

    标签: apache dynamic url-rewriting subdomain


    【解决方案1】:

    你试过了吗

    重写引擎开启 RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC] RewriteCond %{HTTP_HOST} ^([a-z0-9]+)\.example\.com$ [NC] RewriteRule ^/(.*)$ index.php?url=%1&path=$1 [L,QSA]

    还是这样的?

    【讨论】:

    • 是的,我相信。似乎没有工作。特别是结合其他规则摆脱 www。和尾部斜杠等。
    • 你可以尝试在最后一次RewriteCond后添加RewriteCond $1 !^index\.php
    • 你给我的剪辑中的最后一个 rewriteCond 还是我的 htaccess?
    • 我的 sn-p 中的最后一个 RewriteCond。如果你想得到这样的查询index.php/subdomain,那么你可以尝试添加RewriteCond %{QUERY_STRING} !^index\.php/$1
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-27
    相关资源
    最近更新 更多