1

I would like to redirect a subdomain of an old domain to a directory on a new domain.

e.g. forum.old-domain.com should redirect to new-domain.com/forum The redirection from old-domain.com to www.new-domain.com is working, except for the subdomain.

the htaccess is looking like this:

Options +FollowSymlinks
RewriteEngine on

rewritecond %{http_host} ^forum\.old-domain\.de [nc]
rewriterule ^(.*)$ http://www.new-domain.de/forum/$1 [r=301,nc,l]

rewritecond %{http_host} !^www.new-domain.de [nc]
rewriterule ^(.*)$ http://www.new-domain.de/$1 [r=301,nc,l]

# rewritecond %{http_host} ^forum.old-domain.de [nc]
# rewriterule ^(.*)$ http://www.new-domain.de/forum/$1 [r=301,nc,l]

rewritecond %{http_host} ^old-domain.de [nc]
rewriterule ^(.*)$ http://www.new-domain.de/$1 [r=301,nc,l]

rewritecond %{http_host} ^www.old-domain.de [nc]
rewriterule ^(.*)$ http://www.new-domain.de/$1 [r=301,nc,l]

The problem is that forum.old-domain.com redirects to www.new-domain.com but I want it to redirect to www.new-domain.com/forum. Any suggestions? What am I missing?

Thanks in advance!

EDIT:

Added virtual host entries:

maindomain new-domain.com config:

<VirtualHost *:80>
        ServerName new-domain.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/www/new-domain.com/htdocs
        ServerAlias www.new-domain.com
</VirtualHost>

maindomain old-domain.com config:

<VirtualHost *:80>
        ServerName old-domain.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/www/new-domain.com/htdocs
        ServerAlias www.old-domain.com
</VirtualHost>

subdomain old-domain.com config:

<VirtualHost *:80>
        ServerName forum.old-domain.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/www/new-domain.com/htdocs/forum
        ServerAlias forum.old-domain.com
</VirtualHost>
2
  • I guess you are using debian. How does your virtual host configuration looks like? Please post the obfuscated virtual host entries for the new ald the old subdomain.
    – JavaDM
    May 25, 2016 at 11:04
  • Added the virtual host entries in the first post.
    – TK1990
    May 25, 2016 at 11:23

0

You must log in to answer this question.

Browse other questions tagged .