使用的.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]
![解决 安装或卸载软件时报错Error 1001 的问题](https://p.xsw88.cn/allimgs/daicuo/20230902/4.png)
在
的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.
相关推荐
最新文章