We are in the process of migrating this forum. A new space will be available soon. We are sorry for the inconvenience.

redirecting http:// to www help

15-07-2012, 19:53
Try this:

RewriteEngine On

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

RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
RewriteRule index\.html$ / [R=301,L]
edit domain.co.uk and index\.html to your own domain and index file. You might need to remove the 2nd set of rules if you have issues with your site (some sites rely on the index file to work).

15-07-2012, 16:32

I purchased a domain and have basic 10mb free web hosting.

Im trying to get my domain to redirect from http:// to www automatically as for some reason my google ads dont like showing on http:// only www.

Ive ftp'd into the hosting and i see the Htaccess file and edited it using the following:

(i have replaced "yoursite.com" with my own)

# Redirect non-www urls to www
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.yoursite\.com
RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]

But for some reason it doesnt seem to be working. I have tried the same method on my cpanel host using another domain and it works. Just cant seem to get it working with the OVH hosting.