简体   繁体   English

.htaccess将domain.com重定向到www.domain.com

[英].htaccess redirect domain.com to www.domain.com

I am looking for a .htaccess redirect such that all request that come in for mydomain.com are redirected to www.mydomain.com. 我正在寻找一个.htaccess重定向,以便mydomain.com的所有请求都被重定向到www.mydomain.com。 It is important tho that any sub domain request is not affected ie request for sub.domain.com should not be redirected. 重要的是,任何子域请求都不会受到影响,即不应重定向对sub.domain.com的请求。

If found this which seems to do the opposite of what I want: 如果发现这似乎与我想要的相反:

RewriteCond %{HTTP_HOST} ^www\.purchase\.
RewriteRule (.*) http://purchase.DOMAIN_NAME/$1 [L,R]

Thanks in advance for your help 在此先感谢您的帮助

Regards Gabriel 关心加布里埃尔

rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

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

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