cancel
Showing results for 
Search instead for 
Did you mean: 

help with htaccess redirect

spraxyt
Resting Legend
Posts: 10,063
Thanks: 674
Fixes: 75
Registered: ‎06-04-2007

Re: help with htaccess redirect

'Other domain' thoughts.
Since WordPress settings have a single URL, any visitors who arrive on the site using, and retaining, an alternative domain address would appear to change sites (in the address field) as soon as they click an article link. Potentially that's confusing so better, in my view, to change at the start. This would also avoid Google seeing the home page as duplicate content. On that basis any reference to an 'other domain' should be a permanently-moved redirect to the primary URL
I assume the other sites are currently on Homepages; there is no reason why the permanently-moved redirect shouldn't be done from there no need to move them to the ccgi server. This would require an .htacess file in /htdocs on Homepages with contents like

RewriteEngine On
# Redirect other domains to primary one
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.co\.uk$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com$ [NC]
RewriteRule (.*) http://www.domain.co.uk [R=301,L]

You mentioned the sites currently have pages (file paths) on Homepages - I have assumed these will be meaningless to WordPress so ignored them in the redirect.
If these sites are currently in subdirectories defined in the Domain Control Panel I am unsure if Apache backtracks into /htdocs to look for a .htaccess . If you find the above code is ignored, you could temporarily replace it with the one line .htaccess

This should give a 500 Internal Server Error

browse to one of the sites and see if you *do* get that 500 error page. If not it confirms the file is not being read by Apache. The problem can be fixed by changing control panel settings to point the domains to the /htdocs root.
Hope this makes sense. Smiley
David
David
andydg
Grafter
Posts: 46
Thanks: 10
Registered: ‎16-03-2010

Re: help with htaccess redirect

Hi, don't want to hijack this thread, but I could do with a bit of help here too ..
I have a wordpress site running quite nicely in my ccgi space, and have been trying to add a second (different) site which I can't seem to get working properly.
The original website is under its own subdirectory (eg public/subdirone/) and accessed using my domain name (eg. domainone.co.uk).
I have set up the .htaccess file in public which (seems) to have been working fine.
Having now added the second (separate) wordpress site in its own subdirectory (public/subdirtwo/), and asked plusnet to point my second domain name to my ccgi space, I have amended the .htaccess in /public to try and redirect the two domains to the relevant directory.
The second redirect doesn't seem to work and just goes to a random (so far untraceable) error page. I'm not sure whether my htaccess is incorrect, the plusnet redirect hasn't worked or something else is amiss.
This is the version of .htaccess I currently have (under /public/):
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domainone\.co\.uk$ [NC]
RewriteCond %{REQUEST_URI} !^/subdirone/
RewriteRule (.*) /subdirone/$1
RewriteCond %{HTTP_HOST} ^(www\.)?domaintwo\.co\.uk$ [NC]
RewriteCond %{REQUEST_URI} !^/subdirtwo/
RewriteRule (.*) /subdirtwo/$1

The domain configuration on my force9 account is identical for the two domains ('a' record for domain name, 'cname' www - ccgi etc) and have waited a few days from switch over (the second domain used to point to my personal force9 account) for dns to propagate.
I have put a basic htm file in the second directory as a test and can access that by using ccgi.username.force9.co.uk/subdirtwo/ - using the domaintwo.co.uk just fails to a wp 'not found' page.
Am stumped as to why second rewrite doesn't seem to work. Is there any way to trace where the url is landing?  Huh
Any help appreciated ...
spraxyt
Resting Legend
Posts: 10,063
Thanks: 674
Fixes: 75
Registered: ‎06-04-2007

Re: help with htaccess redirect

The content of that .htaccess looks OK to me. You mentioned Plusnet pointing domaintwo to your ccgi space - as well as changing DNS have they also added domaintwo to the ccgi server configuration aliases? I wonder if that is configured correctly?
For checking purposes I suggest disabling the domaintwo redirect lines in .htaccess (insert # as the first character in each of the three lines). If you then browse to each of
www.domainone.co.uk
ccgi.username.force9.co.uk/subdirone/
www.domainTWO.co.uk/subdirONE/ ; (capitals for emphasis)
they should all take you to the WordPress front page for the domainone installation.
ccgi.username.force9.co.uk/subdirtwo/
www.domaintwo.co.uk/subdirtwo/
should take you to the WordPress front page for the domaintwo installation.
Do these behave as expected?
David
David
andydg
Grafter
Posts: 46
Thanks: 10
Registered: ‎16-03-2010

Re: help with htaccess redirect

David, thanks for the reply.
The direct ccgi.username .. url does indeed work in both instances, it is the new domain name that just goes to a seemingly random wp page : 'Not Authorized to View This Page [CFN #0004]' , with no way of determining quite where that page is (?). Changing the htaccess seems to have no effect.
As said, this domain move has only been actioned in the last few days by plusnet tech, a DNS check shows the domain pointing to my ccgi space, so perhaps it is the server configuration aliases ??
Is there a way to check that? Or do I need to ask plusnet ...
spraxyt
Resting Legend
Posts: 10,063
Thanks: 674
Fixes: 75
Registered: ‎06-04-2007

Re: help with htaccess redirect

It does look as though the domain alias for domaintwo could be incorrectly configured. That is something Plusnet would have to check.
Have you checked the content of any .htaccess files in your ccgi root ( / ) and that WordPress created in /public/subdirtwo ?
David
David
bobpullen
Community Gaffer
Community Gaffer
Posts: 16,887
Thanks: 4,979
Fixes: 316
Registered: ‎04-04-2007

Re: help with htaccess redirect

Should be sorted. I've added some comments to your open ticket Andy.

Bob Pullen
Plusnet Product Team
If I've been helpful then please give thanks ⤵

andydg
Grafter
Posts: 46
Thanks: 10
Registered: ‎16-03-2010

Re: help with htaccess redirect

Thanks Bob (and David)  all seems ok now.  Smiley