Redirect "domain.com" to "www.domain.com"

#1
In apache, I used Redirect Permanent in a vhost for "domain.com".

In litespeed, I've set up a listener on www.domain.com. WHY does it also work when I connect to domain.com ???

I just want domain.com to redirect to www.domain.com ...seems simple :)

Any help apreciated,

Florent J.
 

PSS

Well-Known Member
#4
How do I setup that "simple redirect rule" ?

I checked http://www.litespeedtech.com/suppor...eed:wiki:feature:internal_redirect&s=redirect

but I don't get it...
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

# For sites running on a port other than 80
RewriteCond %{HTTP_HOST} !^fully\.qualified\.domain\.name [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{SERVER_PORT} !^80$
RewriteRule ^/(.*) http://fully.qualified.domain.name:%{SERVER_PORT}/$1 [L,R]

# And for a site running on port 80
RewriteCond %{HTTP_HOST} !^fully\.qualified\.domain\.name [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://fully.qualified.domain.name/$1 [L,R]

--

And I use this to redirect www to non-www (the way I like it):

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

I think rewrites like that should include 301 in order to get robots note the end location only.
 
Last edited:
Top