homepage Welcome to WebmasterWorld Guest from 54.161.191.254
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Redirect using Redirectmatch and wildcards
for change of domain situation.
johoney




msg:3805439
 7:56 pm on Dec 11, 2008 (gmt 0)

Given that the new domain will be structurally identical to the old domain will the following redirect be comprehensive enough to redirect everything to its new place on the new domain?

RedirectMatch 301 ^(.*)?(.old-domain.com)/(.*)$ [$1.new-domain.com...]

 

g1smd




msg:3805470
 8:24 pm on Dec 11, 2008 (gmt 0)

The domain name is not available to the RedirectMatch.

It isn't clear if the new domain is on the same server or not, and that affects what code you do need to use.

I would use a RewriteCond to test the %{HTTP_HOST} and a RewriteRule with [R=301,L] to redirect only those requests.

jdMorgan




msg:3805497
 8:46 pm on Dec 11, 2008 (gmt 0)

No, I think not. The expression on the left side can include only the local URL-path, not the domain. Therefore mod_alias directives cannot do what you appear to want to do here. Use mod_rewrite:

RewriteCond %{HTTP_HOST} ^([^.]+\.)?old-domain\.com
RewriteRule (.*) http://%1new-domain.com/$1 [R=301,L]

This assumes that you've got other working mod_rewrite code, and so have the required 'set-up' directives (Options +FollowSymLinks" and "RewriteEngine on") in your file.

Jim

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