【问题标题】:Laravel. redirects between subdomains拉拉维尔。子域之间的重定向
【发布时间】:2017-10-21 19:59:38
【问题描述】:

我想将所有带或不带 www 的 URL 重定向到特定的子域。

示例: example.comwww.example.comcn.example.com

我看到有人说通过在公共场合编辑 .htaccess 文件就可以了,这就是我的 .htaccess 文件中的内容:

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

【问题讨论】:

    标签: php .htaccess redirect laravel-5


    【解决方案1】:

    rewriteengine下面使用这条规则,

    RewriteCond %{HTTP_HOST} ^(www\.)?\.example.com
    RewriteRule ^ cn.example.com [R=301]
    

    【讨论】:

      【解决方案2】:

      这会保留请求路径和参数:

      RewriteCond %{HTTP_HOST} ^example.com$ RewriteRule ^$ subdomain.example.com/$1 [L,R=301]

      【讨论】:

        猜你喜欢
        • 2014-12-21
        • 1970-01-01
        • 2018-05-29
        • 2020-06-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-05-26
        • 1970-01-01
        相关资源
        最近更新 更多