当我尝试删除的www preFIX Yii的错误 [英] Yii error when i try remove www prefix
问题描述
使用的.htaccess我成功地从URL中删除的index.php。 为了获得良好的搜索引擎优化的做法,我需要去除WWW preFIX。组合的两个阿帕奇规则给出了一个错误。
我型www.site.com,我有site.ru - OK!
我型www.site.com/catalog,我得到site.ru - 错误!它的主页。
我型www.site.com/page/some_page,我得到了网站/ index.php文件/ some_page - 错误!
(注:规则页/=>网站/网页,产品目录/'=>'网站/目录/')
的.htaccess
RewriteEngine叙述上
选项+的FollowSymLinks
从WWW #REDIRECT
的RewriteCond%{HTTP_HOST} ^ WWW \。(。*)[NC]
?(*)重写规则^ / HTTP://%1 / $ 1 [L,R =永久]
从URL #remove的index.php
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则。的index.php [L]
尝试,
的RewriteCond%{HTTP_HOST} ^ www.example.com $ [NC]
重写规则^(。*)$ http://example.com/$1 [R = 301,L]
在
的RewriteCond%{HTTP_HOST} ^ WWW \。(。*)[NC]
?(*)重写规则^ / HTTP://%1 / $ 1 [L,R =永久]
希望这会有所帮助。
With .htaccess i successfully remove index.php from url. For good SEO practice I need to remove WWW prefix. Combination two Apache rules gives an error.
I type www.site.com, i got site.ru - ok!
I type www.site.com/catalog, i got site.ru - error! its main page.
I type www.site.com/page/some_page, i got site/index.php/some_page - error!
(note: rules 'page/' => 'site/page', 'catalog/' => 'site/catalog/',)
.htaccess
RewriteEngine on
Options +FollowSymLinks
#redirect from WWW
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^/?(.*) http://%1/$1 [L,R=permanent]
#remove index.php from url
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
Try,
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
In place of
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^/?(.*) http://%1/$1 [L,R=permanent]
Hope it would help.
这篇关于当我尝试删除的www preFIX Yii的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!