Forum Moderators: phranque

Message Too Old, No Replies

Redirect from a domain.com to subdomain.domain.com

I want to move a all the content that is in the domain to a subdomain

         

jmesam

3:02 am on Mar 3, 2005 (gmt 0)

10+ Year Member



Hello,
I'd like to redirect (301) all the content on:
www.domain.com; www.domain.com/dir/; www.domain.com/dir2/index.htm

to subdomain.domain.com,subdomain.domain.com/dir/, subdomain.domain.com/dir2/index.htm

How can I do it?

Thank you in advance

jdMorgan

3:35 am on Mar 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



jmesam,

Welcome to WebmasterWorld!

This is fairly easy to do using mod_rewrite. Perhaps the references provided in our forum charter [webmasterworld.com] will help get you started.

The 'pieces' that you'll need are mod_rewrite's RewriteCond directive, used to test and extract the currently-requested domain and subdomain (test the %{HTTP_HOST} variable), and RewriteRule, to test the requested URL-path, build the new URL using back-references to the hostname and requested 'page', and generate the 301 redirect.

There are also many examples of using mod_rewrite to test and change subdomains posted here in this forum, some very recent. Examining the code in those posts and reading the discussion may prove worthwhile.

Jim