cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple URL's 301 Redirect Required

draycast
Newbie
Posts: 8
Registered: ‎17-05-2013

Multiple URL's 301 Redirect Required

Hi,
I have searched through many articles and forums now to find the answer and a method to achieve what I'm trying to do. We have several URL's for our main website - www.draycast.co.uk - which are www.sandcastings.co.uk, www.aluminium-bronze-castings.com & draycast.co.uk (non www). I understand these are acting as 4 separate sites which is having an effect on our Google rankings because of the duplication. I have been told that we need to set up 301 redirects to www.draycast.co.uk from the other URL's to prevent this. I have seen from several articles that I need to put the redirect in the .htaccess file to stop duplication. When I have connected to our site server with CuteFTP I find that there isn't a file called this and just an .htdocs file with all the webpages from the main site on it. My question is why do I not have an .htaccess file showing and can I create one. Also if I do have an .htaccess file (I understand it may be hidden but even so I still can't find it) do I put 3 entries in it for the 3 sites I'm trying to redirect. This bit I don't really understand as I can't see how the 3 sites are working as I have only one webspace. There must be something somewhere telling a browser to access the website I've uploaded to www.draycast.co.uk when someone views www.sandcastings.co.uk for example. Sorry if this seems laboured but most of the information I've read seems to require a level of knowledge in HTML that is above me so any help in basic language would be really appreciated. I'm using Webplus 6 to produce my site if this has any bearing on things.
16 REPLIES 16
kmilburn
Grafter
Posts: 910
Thanks: 3
Registered: ‎30-07-2007

Re: Multiple URL's 301 Redirect Required

Quote from: draycast
why do I not have an .htaccess file showing and can I create one.

A .htaccess file will only exist within your site if you've created it, it's a directory level configuration file, so where it appears has an effect on the servers behaviour.
In this instance,  you want to create one with the appropriate settings and put it in the root of your site (so it end up inside htdocs).
Quote from: draycast
This bit I don't really understand as I can't see how the 3 sites are working as I have only one webspace. There must be something somewhere telling a browser to access the website I've uploaded to www.draycast.co.uk when someone views www.sandcastings.co.uk for example.

As far as the browser is concerned,  it has no idea that the sites are related as it is only interested in the URL for the pages and images.
The server handles the incoming requests, parses the URL used and fetches the files from the appropriate location,  then returns the files with the appropriate URL based on the request.
The fact that the server looks into the same folder for the different sites is irrelivant to it too.
Unfortunately,  I suspect this will pose a problem,  as each site will have the same .htaccess file and will cause a redirect,  including the main site redirecting to itself!
Hopefully someone with more knowledge of writing .htaccess files may be able to help with that.

BTW,  you sandcastings site appears to be hosted seperately (going from the IP address it resolves too),  so you could move the two sites that need redirecting to one address with the main site on the other.
Superuser
Superuser
Posts: 10,018
Thanks: 1,340
Fixes: 71
Registered: ‎06-04-2007

Re: Multiple URL's 301 Redirect Required

Using DIG to check the DNS records shows all domains go to the homepages servers so it is up to the domain maps (created by Plusnet) to direct them to your webspace. The three www addresses use CNAME entries, the equivalents without www use A records.
On homepages redirecting has to be done using mod_alias simple redirects which are intended for redirecting to a different site. Trying to use them to redirect to the same site (using its preferred name) would, as kmilburn mentioned, also redirect the preferred address causing an infinite loop.
One way to avoid this problem is to use the Member Centre Control Panel to change domain mapping for the two alternate domains to a subdireciory of /htdocs, then use a .htaccess file in that subdirectory to redirect to the preferred domain in the webroot (/htdocs) directory.
Let's assume you call the subdirectory /alternates (any name will do, as long as it differs from anything in use on the site).
The .htaccess file that goes in that subdirectory needs to contain
[code=.htaccess]
Redirect permanent /alternates http://www.draycast.co.uk[/code]
Note that .htaccess needs to be created as a plain text file using (for example) Notepad on Windows, then uploaded as ASCII to change line endings to Linux style. On Windows it is often easier to create and upload it as htaccess.txt, then rename it to .htaccess using your FTP program. The FTP program needs to be configured to show hidden files to make .htaccess visible.
To test this is working visit www.sandcastings.co.uk/alternates - you should find this is redirected to www.draycast.co.uk with that site's home page displayed and its address in the browser. Similarly for the other domain and for their non-www versions. Assuming this works if you now use the Control Panel to change domain mapping to direct those alternate sites to the /htdocs/alternates subdirectory the change should come into use without affecting visitors.
This still leaves www.draycast.co.uk and its non-www equivalent pointing to the same (duplicate) content. For Google I think one can use Webmaster tools to specify the www form is the preferred canonical name.
Edit:
I think for all search engines it is permissible to add a link tag with rel=canonical in the head section of the site's index.html file pointing back to itself as a hint that the www form of the page is the preferred link. Thus:
[code=for link tag in head section of page]
<link rel="canonical" href="http://www.draycast.co.uk">[/code]
David
draycast
Newbie
Posts: 8
Registered: ‎17-05-2013

Re: Multiple URL's 301 Redirect Required

Thank you very much for your comments and instructions. I think am getting there slowly. I've followed your detailed instructions spraxyt but something seems to be missing. When I type www.sandcastings.co.uk/alternates in the browser it redirects as you describe and the search bar shows www.draycast.co.uk etc. But when I just type www.sandcastings.co.uk it goes as before to the www.sandcastings.co.uk site. When you say 'Assuming this works if you now use the Control Panel to change domain mapping to direct those alternate sites to the /htdocs/alternates subdirectory' do you mean on PlusNet site going to domain names then selecting the appropriate domain name, then configure, typing the alternates in the box after htdocs and then submitting this? There are 2 buttons here also for default and other, do I leave on default or does the other select the alternates typed in the box. Could you or anyone else clarify if this is what you mean. Thanks again for your help its very much appreciated.
Superuser
Superuser
Posts: 10,018
Thanks: 1,340
Fixes: 71
Registered: ‎06-04-2007

Re: Multiple URL's 301 Redirect Required

The behaviour for the alternate sites is as I expected at this stage. Both of your alternate domains, with or without www, are redirected to the preferred site when the /alternates subdirectory is requested.
Without /alternates the behaviour is (currently) the same as it was before because the redirection affects only the /alternates folder and we aren't going there. The second part of the change via the Domain names Control Panel should fix this.
So yes, you need to login to the Member Centre on your Plusnet account, select Domain names then Configure for your sandcastings.co.uk domain. In the Domain Hosting Settings section you leave the Default radio button selected and type alternates in the text box alongside /htdocs/. Then click the Submit button.
This will cause the domain maps on the server to be changed so that visitors to www.sandcastings.co.uk (with or without www) are sent to the /alternates folder from where they are redirected to the main site under its preferred name.
A similar change needs to be made for the aluminium-bronze-castings.com domain (but draycast.co.uk is NOT changed).
Once these changes take effect (overnight?) visitors to www.sandcastings.co.uk, again with or without www, should be redirected to the preferred site. In the meantime behaviour will be unaffected - no one should get a 404 page-not-found error.
The final step is to put that <link rel="canonical" ...> tag in the head section of the site's index.html file as a hint to search-engine crawlers that the www link to the page is the preferred reference. Note this should go only in that index.html file, other files seem to be addressed by absolute addresses which are the preferred form.
David
draycast
Newbie
Posts: 8
Registered: ‎17-05-2013

Re: Multiple URL's 301 Redirect Required

OK, I've now done that change in domains control panel again. I changed both sites to htdocs/alternates and then checked but nothing happened so changed it back as I didn't realise that it would take time to come into effect. Patience is a virtue and all that!!! It now appears that the sites go to a fairly blank page that says 'Index of /' at the top. I'm not sure if this is a transitional stage or something else is wrong. I haven't done the change to the index.html file yet as I'm not sure how to edit it. I'm guessing its within the Webplus program I use to do the site, I'll look into this when I get a minute. I have made the changes in webmaster tools to specify the www form is the preferred canonical name so this should help at least for the time being. Thanks again for your patient help, its a complete mine field for me.
Superuser
Superuser
Posts: 10,018
Thanks: 1,340
Fixes: 71
Registered: ‎06-04-2007

Re: Multiple URL's 301 Redirect Required

The problem still occurs so I wouldn't expect it to be a transitional effect, I think something is wrong. Have you by any chance got a stray 'space' or 'newline' character in the directory textbox (where you typed alternates)?
My suggestion is to backspece in that textbox to make sure it is empty then type alternates again, submit - and be patient.
David
draycast
Newbie
Posts: 8
Registered: ‎17-05-2013

Re: Multiple URL's 301 Redirect Required

I've deleted and then retyped the alternates in the box after htdocs last night but it is still the same this morning. Should I just leave it and see if it recovers or is there anything else you can suggest. Its strange that when browsing www.sandcastings.co.uk/alternates it works.
Community Veteran
Posts: 767
Registered: ‎29-10-2008

Re: Multiple URL's 301 Redirect Required

Try changing the .htaccess in the alternates directory to read
Redirect permanent / http://www.draycast.co.uk

Gabe
Superuser
Superuser
Posts: 10,018
Thanks: 1,340
Fixes: 71
Registered: ‎06-04-2007

Re: Multiple URL's 301 Redirect Required

I assume that change has been done now, thanks Gabe for spotting that. Though this works on the bare directory I think it needs it needs a / on the end, thus…
[code=.htaccess]
Redirect permanent / http://www.draycast.co.uk/[/code]
… so that a request for a particular file via an alternate domain, eg www.sandcastings.co.uk/uk_aluminium_bronze_casting_production_foundry.html doesn't redirect to www.draycast.co.ukuk_aluminium_bronze_casting_production_foundry.html (which doesn't exist).
David
draycast
Newbie
Posts: 8
Registered: ‎17-05-2013

Re: Multiple URL's 301 Redirect Required

I have made both changes as suggested by you both and it appears that all is well as both of the alternate sites seem to be redirecting to the right place. I will now investigate the other issue with the index file and see how I change this. Many thanks again for your help in helping me implement the changes to prevent me having duplicate sites out there.
Community Veteran
Posts: 767
Registered: ‎29-10-2008

Re: Multiple URL's 301 Redirect Required

To redirect draycast.co.uk (and anything else) to www.draycast.co.uk, you can place a .htaccess file in your htdocs directory:
RewriteEngine  on
RewriteCond %{HTTP_HOST} !^www\.draycast\.co\.uk [NC]
RewriteRule ^(.*) http://www.draycast.co.uk/$1 [L,R=301]

You shouldn't need the redirects via /alternates. All domains can point at htdocs, subject to this rewrite. Though, having got it working that way, you could just leave it.
Gabe
draycast
Newbie
Posts: 8
Registered: ‎17-05-2013

Re: Multiple URL's 301 Redirect Required

Gabe, I've added the code in your last post to a new .htaccess file in htdocs directory. This redirects the draycast.co.uk to www.draycast.co.uk but the other 2 sites www.sandcastings.co.uk & www.aluminium-bronze-castings.com now do not work at all. It shows in the address bar on Safari on my ipad that it is trying to redirect to www.draycast.co.uk/alternates. Can you suggest what is going wrong. Thank you.
Community Veteran
Posts: 767
Registered: ‎29-10-2008

Re: Multiple URL's 301 Redirect Required

It's looping. To use the rewrite method, you would need to remove the redirects, i.e. remove alternates from the control panel for each of the other domains, and remove the .htaccess file in alternates. So all domains would now point at htdocs.
Sorry, I should have been clearer: it's a simpler and more comprehensive alternative to the redirects, not an addition to the redirects. Apologies for the confusion.
Gabe
draycast
Newbie
Posts: 8
Registered: ‎17-05-2013

Re: Multiple URL's 301 Redirect Required

I've removed the .htaccess file from the htdocs folder at the moment so it doesn't stop the other 2 sites working. So going forward are you saying delete the .htaccess file from the alternates folder, remove the redirects to the alternates folder in control panel and then reinstate the .htaccess file in htdocs folder. Do I need to add anything else to the .htaccess file in the htdocs folder though? It looks like it will only direct the draycast.co.uk to www.draycast.co.uk from the code (the little I understand of it!). Do I need to add redirects for the other 2 domains to this .htaccess file and if so could you be so kind to give me the code for this. Many thanks.