简体   繁体   中英

.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. It is important tho that any sub domain request is not affected ie request for sub.domain.com should not be redirected.

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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