Welcome to WebmasterWorld Guest from 54.147.10.72

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Redirect using Redirectmatch and wildcards

for change of domain situation.

     

johoney

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

5+ Year Member



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

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

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



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

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

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



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

 

Featured Threads

Hot Threads This Week

Hot Threads This Month