【问题标题】:redirect from www to non www in Yii Framework在 Yii 框架中从 www 重定向到非 www
【发布时间】:2014-10-16 19:12:57
【问题描述】:

如何正确地从 www 重定向到非 www url?
我使用这行:

RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

但它们效果不佳。他们在地址中添加了andex.php并删除了第一个由/ /四舍五入的exp。

http://www.payamkadeh.com/profile/show/behtateam -> http://payamkadeh.com/index.php/show/behtateam

我的完整 htaccess:

RewriteEngine On
Options +FollowSymlinks
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

#RewriteBase /
#RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L

【问题讨论】:

    标签: apache .htaccess mod-rewrite redirect yii


    【解决方案1】:

    在内部路由前有 www 重定向规则:

    Options +FollowSymlinks
    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L,NE]
    
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php [L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-28
      • 2010-11-09
      相关资源
      最近更新 更多