好吧,我正在使用此代码重定向域和ip:
RewriteEngine On
rewritecond %{http_host} ^www.lucrebem.com.br [nc]
rewriterule ^(.*)$ http://lucrebem.com.br/$1 [r=301,nc]
RewriteRule ^(.*)['"$] /$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^216'.245'.194'.194
RewriteRule (.*) http://lucrebem.com.br/$1 [R=301,L]
它的作用是从 url 中删除 www,但问题是,如果用户点击 www.mysite.com/thecategory/thearticle
,他不会被重定向到 mysite.com/thecategory/thearticle
,他将被重定向到 mysite.com/index.php
这不是我想要实现的目标,我相信这会影响我的排名。
我会这样做,您可以将规则合并为一个而不是单独的规则。
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www'.lucrebem'.com'.br [NC,OR]
RewriteCond %{HTTP_HOST} ^216'.245'.194'.194
RewriteRule ^ http://lucrebem.com.br%{REQUEST_URI} [R=301,L]
伙计,这应该删除www
并将其重定向到域 + slugs:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
<VirtualHost *:80>
ServerName www.example.com
Redirect permanent / http://example.com/
</VirtualHost>
或
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www'.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
这是我修复它的方法:
### Makes www Redirect to non-www without redirecting to index page
RewriteCond %{HTTP_HOST} ^www'.lucrebem'.com'.br
RewriteRule (.*) http://lucrebem.com.br/$1 [R=301,L]
对于想要重定向 IP 的人来说,这是一个奖金:
#Redirects IP, working fine, don't change anything below
RewriteCond %{HTTP_HOST} ^216'.245'.194'.194
RewriteRule (.*) http://lucrebem.com.br/$1 [R=301,L]
:)