How to redirect

Hi,

I am not sure if this is the right forum, it doesnt relly seem to fit in anywhere.

I have built a website and checking it in woorank to see what problems there were. Ome of the issues it said I should be aware of was that the two domains [noparse]http://www.web-writer-articles.co.uk[/noparse] and [noparse]http://web-writer-articles.co.uk[/noparse] were not seem as duplicate.

It put it like this:

Be sure that [noparse]http://web-writer-articles.co.uk[/noparse] and [noparse]http://www.web-writer-articles.co.uk[/noparse] are not running in parallel.

Redirecting requests from a non-preferred hostname is important because search engines consider URLs with and without “www” as two different websites.

Once your preferred domain is set, use a 301 redirect for all traffic to your non-preferred domain.

  1. So my question is: how do i set a preferred hostname?
  2. How do I set the 301 re-direct?

thanks for your help

cass27

Yes, it’s important to choose whether to use www or not. Once you’ve chosen, it’s an Apache issue to lock off the other one.

There is a lot of info on this page:

In post 3, go down to Eliminate www for a Domain. If that doesn’t make sense, post back and this thread can be moved to the Apache forum.

Normally, what you’d do is open the .htaccess file in your root folder (or create one if there isn’t one) and paste in some code like the code on that page.

Hi Ralph,

the whole page seems full of useful info. Unfortunately my knowledge of php is very basivc and I would fear messing around in the htaccess file may cause problems so I htink i will have to get a pro to do it but thanks for your help!

cass27:)

This isn’t a PHP issue, but rather an Apache one. I know nothing about that either, but honestly, I use the following code on all my sites to redirect the www version to the non-www version:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\\.(([a-z0-9_]+\\.)?mysite\\.com)$ [NC]
RewriteRule .? http://%1%{REQUEST_URI} [R=301,L]

As long as your site uses just http://, this code will work fine and won’t do any damage (and if it does, just remove it again). Of course, replace “mysite” with your own domain.

Do you have access to the .htaccess file?

Hi ralph

there is a proble me here-

I want it the other way round. I want to re-direct the non-www version to the www version. in other words the www version is the one i use.

:blush:

regards,

Nick

I used to do it that way, with this:


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

thanks for sticking with this Ralph,:eek: I shall give ait a whirl