例如,我的域是http://www.domain.com,我想重定向到no-www url (http://domain.com),因为我在.htaccess中使用了这个代码。
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]它工作得很好,http://www.domain.com重定向到http://domain.com。
现在我有一个子域http://www.blog.domain.com (public_html/blog)要重定向到no-www url http://blog.domain.com,因为我使用了这段代码。
RewriteCond %{HTTP_HOST} !^blog\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://blog.domain.com$1 [R=301,L]但同时www也不会删除子域url中的内容。我在这里做错了什么?
更新:我的主机提供商是hostgator
发布于 2013-11-05 07:29:29
步骤1:
似乎在/public_html/blog内部也有一个WP的/public_html/blog。在您的/public_html/blog/.htaccess:中WP规则之前添加此规则
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]步骤2:
然后在WP permalink settings中将您的博客地址更改为:
http://blog.domain.comhttps://stackoverflow.com/questions/19782910
复制相似问题