I've seen lots of various examples, and lots of varying opinions on the correct methods to use, most of them for .htaccess with the implication that they will work with httpd.conf , Figured I'd ask the experts here since I'm using lightspeed as my web server.
Desired result: one piece of code that will redirect all the domain names on my server from non www to www
Here are a couple of the most popular solutions I came across.
Method 1:
Would this method work with some wildcards for all domains instead of just one? If so, what would the exact code be?
Method 2:
This seems to do what I think I want, but a few posters said it was "to Heavy handed" of an approach. Not sure what that meant exactly.
Method 3:
I'm looking for the cleanest solution that works well on lightspeed?
Thanks,
Jason
Desired result: one piece of code that will redirect all the domain names on my server from non www to www
Here are a couple of the most popular solutions I came across.
Method 1:
Code:
<VirtualHost *:80>
ServerName example.com
Redirect permanent / http://www.example.com/
</VirtualHost>
Method 2:
Code:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Method 3:
Code:
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ %{REQUEST_SCHEME}://www.%{HTTP_HOST}$1 [R=301,L]
Thanks,
Jason
Last edited by a moderator: