简体   繁体   English

将www重定向到新的子域

[英]Redirect www to new subdomain

I want to redirect www.acme.com to subdomain.acme.com 我想将www.acme.com重定向到subdomain.acme.com

What I have so far: 到目前为止,我有:

RewriteEngine on
RewriteRule ^http://www.acme.com/(.*)$mysubdomain.acme.com/$1 [R=301,L]

This needs to work for page links with and without 'http://' 这需要使用带有和不带有“ http://”的页面链接

Thank you. 谢谢。

EDIT*** adding my complete .htaccess 编辑***添加我完整的.htaccess

RewriteEngine on
RewriteBase /
#RewriteRule (.*)\.html $1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your DOCUMENT_ROOT/.htaccess file: 通过httpd.conf启用mod_rewrite.htaccess ,然后将此代码放入DOCUMENT_ROOT/.htaccess文件中:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:www\.)?(acme\.com)$ [NC]
RewriteRule ^ http://subdomain.%1%{REQUEST_URI} [NE,R=301,L]

This will do permanent redirect of every URI from www.acme.com OR acme.com to subdomain.acme.com . 这会将每个URI从www.acme.com acme.com永久重定向 subdomain.acme.com

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.acme.com
RewriteRule ^(.*)$ http://subdomain.acme.com/$1 [L,NC,QSA]

Try something like... 尝试类似...

RewriteCond %{HTTP_HOST} !^subdomain\.acme\.com [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http://subdomain.acme.com/$1 [L,R=301]

The conditions are: "if the host doesn't match subdomain or is unset." 条件是:“如果主机与子域不匹配或未设置”。 With the acton of: redirect any provided URI to that new Host and preserve the URI. 使用acton of:将提供的任何URI重定向到该新Host并保留URI。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM