Jump to content

redirect to www


MSUK1

Recommended Posts

Oops, didn't properly read the question. Yeah, it'd be best to use rewrite rules in .htaccess or httpd.conf, something like this:

 

RewriteEngine on

RewriteCond %{HTTP_HOST}  !^www.domain.com [NC]

RewriteCond %{HTTP_HOST}  !^$

RewriteRule ^/(.*) http://www.domain.com/$1 [R,L]

 

If you went a PHP route you'd need to make the redirect conditional.

Link to comment
https://forums.phpfreaks.com/topic/217757-redirect-to-www/#findComment-1130327
Share on other sites

also what is all of this thats already in my .htaccess file

# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName msukgroup.co
AuthUserFile /home/msuk/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/msuk/public_html/_vti_pvt/service.grp
   

 

 

i then edited my ht to this: and it doesnt work :/

# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName msukgroup.co
AuthUserFile /home/msuk/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/msuk/public_html/_vti_pvt/service.grp
   
RewriteEngine on
RewriteCond %{HTTP_HOST}   !^www.msukgroup.co [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)    http://www.msukgroup.co/$1 [R,L]

 

Link to comment
https://forums.phpfreaks.com/topic/217757-redirect-to-www/#findComment-1130378
Share on other sites

here is how I redirect to www using .htaccess:

 

RewriteEngine on
RewriteBase /

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

 

The $1 is the content of the (.*). it says "take everything that follows mydomain.com and paste it onto the end of www.mydomain.com"

Link to comment
https://forums.phpfreaks.com/topic/217757-redirect-to-www/#findComment-1130427
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.