homepage Welcome to WebmasterWorld Guest from
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.

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



 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.


 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.


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