开发者

How to redirect all urls to a www. subdomain

开发者 https://www.devze.com 2023-02-01 03:43 出处:网络
I\'ve got this rewrite in my .htaccess: RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^domain.com/$ [NC] RewriteRule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

I've got this rewrite in my .htaccess:

RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^domain.com/$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

Which works fine for domain.com but doesn't redirect the URL with something after the /

(domain.com/something.php should redirect to www.domain.com/something.php)

How can this be done?开发者_开发知识库

Thanks in advance!!


check it out

RewriteCond %{HTTP_HOST} !^www\.domain\.com 
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=permanent,L]


My guess its because you write ^domain.com/$ - the dollar sign at the end means end of the string, so nothing can be after it - that is why it works with domain.com, but does not work with something more?

0

精彩评论

暂无评论...
验证码 换一张
取 消