我正在尝试(但失败了)创建一个301重定向条件,将用户可能进入的任何子域(例如anything.mysite.com)和mysite.com all发送到www.mysite.com。这有可能吗?我已经成功地让其中一个运行起来,但不是两个都运行。任何帮助都将不胜感激。
发布于 2015-08-29 08:04:01
您可以在.htaccess中使用
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]发布于 2015-08-29 07:57:05
@John Charles Smith
您可以使用以下任一选项:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^example\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^anything\.example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L,NC]或
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^anything\.example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]https://stackoverflow.com/questions/32281115
复制相似问题