【问题标题】:301 Every request to root (including all subdomains)301对根的每个请求(包括所有子域)
【发布时间】:2013-09-03 13:44:57
【问题描述】:

好的,问题来了

我想将所有请求 301 重定向到 www.domain.com,这应该包括除 www 之外的所有子域。跑题了。

例子

info.domain.com/example > 301 redirect > www.domain.com
www.domain.com/examples > 301 redirect > www.domain.com
domain.com              > 301 redirect > www.domain.com
domain.com/example      > 301 redirect > www.domain.com

我目前的代码是:

    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^/$
    RewriteRule ^.+$ / [R=301,NC,L]  

但这并没有处理通配符子域重定向...

我希望有人可以帮助我。

提前致谢

【问题讨论】:

    标签: apache .htaccess redirect mod-rewrite


    【解决方案1】:
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^/$    [OR]
    RewriteCond %{HTTP_HOST}  !^www\.domain\.com$
    RewriteRule ^.+$   http://www.domain.com/ [R=301,NC,L]  
    

    【讨论】:

    • 不应该是HTTP_HOST吗?
    • 感谢您的回答。现在唯一的事情是它不会将子域的通配符重定向到 www.domain.com 有没有办法合并它?谢谢
    • 是的,你是CPanel direcAdmin
    • 哪一个?面板?还是directAdmin?
    • 很抱歉我用了CPanel
    猜你喜欢
    • 1970-01-01
    • 2021-07-26
    • 2012-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-09
    • 1970-01-01
    相关资源
    最近更新 更多