• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 365
  • Last Modified:

Simple htaccess redirection

Hi Guys,
Quick and easy one (I think!) for someone who knows what they are doing!

I need to redirect our .org domain to the .com domain, but without all .org pages going to the .com index.

For example, I need www.xyz.org to go to www.xyz.com but also www.xyz.org/folder/index.php to go to www.xyz.com/folder/index.php

The directory structure is identical on both domains (which are on separate servers), and we're moving the .com domain.  I'm getting lost in .htaccess can anyone help?  Also need the code the deal with URLs with and without the www part.

Any thoughts?
0
lynxIT
Asked:
lynxIT
1 Solution
 
MountMannCommented:
You can use mod_rewrite for this, see the example of an .htaccess below.
RewriteCond %{HTTP_HOST} ^www.xyz.org$ [NC]
RewriteRule ^(.*)$ http://www.xyz.com/$1 [R=301,L]

Open in new window

0
 
lynxITAuthor Commented:
Thats great - thanks

I've just realised that although the folder structure is the same its all within a html directory, so I'm guessing I could change:

RewriteRule ^(.*)$ http://www.xyz.com/$1 [R=301,L]

to

RewriteRule ^(.*)$ http://www.xyz.com/home/$1 [R=301,L]

and it would work?
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now