Welcome to WebmasterWorld Guest from 54.235.46.164

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Redirect using Redirectmatch and wildcards

for change of domain situation.

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

Junior Member

10+ Year Member

joined:Mar 14, 2006
posts: 49
votes: 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)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 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)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 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