.htaccess - having a bit of a 'mare

Soldato
Joined
27 Jun 2006
Posts
6,333
Hey folks,

Having a nightmare with .htaccess and am seeking the expertise of the forum.

I had a wordpress installation and ip.board installation on a domain under /home and /forum respectively.

I've since changed the domain to a new one - but all the directories and stuff are the same.

The newdomain.com and olddomain.com (for simplicity sake) are both tied into the hosting account now but I only want the newdomain.com as the outright address and olddomain.com as a redirect to the newdomain.com.

Can I do this in .htaccess or am I going to have to release the olddomain.com from the hosting nameservers on my registrar and URL-Forward it via that?

My current settings are:

Code:
RewriteEngine On

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

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

RewriteCond %{HTTP_HOST} ^olddomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/home/$1 [R=301,L]

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

Everything seems to be working fine, excluding the forum (/forum) which gives the message:

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

I feel I've overcomplicated the .htaccess and something much simpler would do but I'm having trouble getting my head around it. My hosting company didn't really seem that concerned either even though they don't support scripting/coding so I suppose I can't complain.

In short, I want olddomain.com/ to point to newdomain.com/home and newdomain.com/ to point to newdomain.com/home - bypassing the index page of the root.

Thanks for any help. I'm out of my depth. :D

-edit-

I've removed:

Code:
RewriteCond %{HTTP_HOST} ^newdomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/home/$1 [R=301,L]

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

And that's did a good job. However, newdomain.com points to the crappy index page instead of going to /home - what is the easiest way around doing this? Planting the redirect into the index?
 
Last edited:
This should do the trick, but it's untested:

Code:
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^(www\.)?newdomain.com$ [NC]
RewriteRule ^(?!home/)(.*)$ /home/$1 [L]

RewriteCond %{HTTP_HOST} ^(www\.)?olddomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]
 
Ended up plumping for:

Code:
Redirect permanent /index.html http://newdomain.com/home

Seemed to do the trick. :)

Thanks for your help.
 
Last edited:
Back
Top Bottom