Solved

Simple htaccess redirection

Posted on 2010-11-09
2
357 Views
Last Modified: 2012-05-10
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
Comment
Question by:lynxIT
2 Comments
 
LVL 1

Accepted Solution

by:
MountMann earned 250 total points
ID: 34097953
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
 
LVL 1

Author Comment

by:lynxIT
ID: 34098289
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now