Jump to content

redirect to www


MSUK1

Recommended Posts

okay, any idea what i should add to my .hta

 

i looked into adding a 301 permanent redirect on domain.com to www.domain.com but that doesnt seem like the official method to me, doesnt seem right?

 

and i dont think that will help with seo

Link to comment
Share on other sites

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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.