homepage Welcome to WebmasterWorld Guest from 54.198.130.203
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

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
alaltaieri




msg:4592265
 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:

olddomain.com
olddomain.com/home/category/page.html
olddomain.com/home/mybook/page2.html

should be 301 redirect to the new newdomain like below:

newdomain.com
newdomain.com
newdomain.com


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]
</IfModule>

# 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.

 

lucy24




msg:4592281
 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
<snip>
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 :)

alaltaieri




msg:4592303
 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.

alaltaieri




msg:4592331
 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.

phranque




msg:4592346
 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