-1

I have got apache2 server with one virtual host. It is typo3 CMS. There are multiple pages:

foo.com -- DNS A record --> 32.32.32.32
  |_ foo.com/bar/
  |_ foo.com/baz/

Now I want to configure other domain (qux.com, also with A record to IP same as below) to redirect it to foo.com/baz/, for example when user put qux.com in browser I want him to see qux.com in address bar and foo.com/baz/ webpage. In order to do this I have put this configuration to file in sites-enabled:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^qux.com
RewriteRule ^(.*) http://foo.com/baz/ [P]

but it has no effect. What is a cause? How to configure it properly?

Edit: here is my vhost config:

<VirtualHost *:80>
        ServerName foo.com
        ServerAlias *.foo.com
        ServerAlias qux.com
        RewriteEngine On
        RewriteCond %{HTTP_HOST} ^qux.com
        RewriteRule ^(.*) http://foo.com/baz/ [P]
        DocumentRoot /var/builds/stage
        <Directory /var/builds/stage>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride all
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>
0

1 Answer 1

1

Wouldn't it be easier to add another VirtualHost?

<VirtualHost *:80>
        ServerName qux.com
        ServerAlias *.qux.com
        Redirect / http://foo.com/baz/
</VirtualHost>
2
  • It is works, but i don't want users see the target URL.
    – Karaal
    Mar 3, 2015 at 10:47
  • With RewriteRule you'll end up redirecting the user to another domain anyway. Still, another VirtualHost is the correct solution. Just replace Redirect directive with DocumentRoot /var/builds/stage/baz/ You really should read link examples first – it's all thoroughly explained there with all the suitable examples. Mar 3, 2015 at 11:08

Not the answer you're looking for? Browse other questions tagged .