Redirect the same URL's from old domain to new subdomain

by hinner
1 replies
Hi,

I would like to automatically redirect all URL's under the "forum" directory in my old domain to the same URL's in my new subdomain.

For example, olddomain.com/forum/topic1 will redirect automatically to subdomain.com/forum/topic1

Likewise, olddomain.com/forum/childforum/topic1 will redirect to subdomain.com/forum/childforum/topic1

The URL's will always be the same, but I want to do this only for those in the forum directory. Does anyone know how to achieve this?

Thanks!
#domain #redirect #subdomain #url
  • Profile picture of the author jlucas
    You can do the redirect by creating an .htaccess file and placing it in olddomain.com/forum/
    I'm making a lot of assumptions here such as: mod_rewrite is active and AllowOverride is on in your apache2 sites-available file. If you have shared hosting, it is a good bet that you are fine.

    The .htaccess file should look something like this:

    Code:
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteRule ^(.*)$ http://sub.domain.com/$1 [R=301,L]
    </IfModule>
    I'm not an .htaccess expert, but I believe that should work out for you.
    {{ DiscussionBoard.errors[9485094].message }}

Trending Topics