homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Redirect all pages from old domain to new domain root page
301 redirect

Msg#: 4592263 posted 10:49 pm on Jul 11, 2013 (gmt 0)

Hi there.
I want to redirect olddomain.com(without www) to newdomain.com(without www)including all the inner pages of old domain to newdomain.com (without www)

It should looks something like this:


should be 301 redirect to the new newdomain like below:


This is what I have in .htaccess file for redirecting at this moment:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) http://newdomain.com/$1 [R=301,L]
RewriteRule . /index.php [L]

# END WordPress

RewriteCond %{HTTP_HOST} ^olddomain\.com$ [OR]
RewriteRule ^/?$ "http\:\/\/\newdomain\.com" [R=301,L]

However, this code it's working for redirecting olddomain.com to newdomain.com

And the inner pages are looking like this:

olddomain.com/home/category/page.html is redirecting to ====> newdomain.com/home/category/page.html and not to newdomain.com like I want.

Can you help me with a code in .htaccess file?

Thank you,appreciated.



WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

Msg#: 4592263 posted 11:22 pm on Jul 11, 2013 (gmt 0)

Raise your hand if you saw the topic title and immediately screamed Noooooo!

This is what I have in .htaccess file

Where? Under the new domain or the old one? Or are they parallel domains in a shared userspace?

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/?$ "http\:\/\/\newdomain\.com" [R=301,L]

... Now wait a minute. I swear I saw this IDENTICAL rule configuration-- IfModule, RewriteEngine On, RewriteRule with conditions, close IfModule, and finally a domain redirect with superfluous escaping-- in another thread no more than two or three days ago. So you can simply dig it up and swipe their answer :)


Msg#: 4592263 posted 11:59 pm on Jul 11, 2013 (gmt 0)

Sorry, I forget to mention that the .htaccess settings that I presented in my first post are placed on the old domain.


Msg#: 4592263 posted 2:18 am on Jul 12, 2013 (gmt 0)

Also, I searched that for that thread about 1 hour and I didn't find anything related to my problem.


WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

Msg#: 4592263 posted 3:30 am on Jul 12, 2013 (gmt 0)

welcome to WebmasterWorld, alaltaieri!

this is the thread lucy24 is referring to with similar issues in your .htaccess file.
creating ip exception for redirect in .htaccess - Apache Web Server forum:
http://www.webmasterworld.com/apache/4591901.htm [webmasterworld.com]

it's almost incredible to see the same set of unusual errors on two consecutive days.

regarding your current .htaccess file:
- before you fix anything you should reconsider your decision to redirect all urls on olddomain.com to the home page of newdomain.com - it's not a good experience for the visitor and google will at best treat this like a soft 404 and at worst penalize you for manipulation of pagerank.
- if you are redirecting all requested urls to another domain you shouldn't have any requirements for an internal rewrite.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved