0

I have two domains, which content is in the same file directory:

http://www.alpha.com/

DIR: /var/www/alpha.com/

and

http://www.beta.com/

DIR: /var/www/beta.com/

I want to do the following thing:

When user goes to

http://www.alpha.com/beta/

he should see the content of

http://www.beta.com

and by going e.g. to

http://www.alpha.com/beta/index.php?a=3&b=2

he should see the content of

http://www.beta.com/index.php?a=3&b=2

and so on.

How can I manage that with htaccess?

And in which directory should I place that?

I thought about that:

RewriteEngine On

RewriteRule ^\.htaccess$ - [F]


RewriteCond %{REQUEST_URI} ^/beta/(var1)$

RewriteRule ^.*$ http://beta.com/%1

But it doesnt work. And I'm not good in regular expressions.

Thank you for every answer!

Max
  • 1

2 Answers2

2

Put the below .htaccess file into /var/www/alpha.com/:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/beta/?$
RewriteRule ^.*$ http://beta.com [L]
RewriteCond %{REQUEST_URI} ^/beta/(.*)$
RewriteRule ^.*$ http://beta.com/%1 [L]
  • question mask ?: makes the preceding token optional
  • L flag: means the last rule
quanta
  • 50,327
  • 19
  • 152
  • 213
0

Do you need to use the .htaccess file? If not, using VirtualHosts in the httpd.conf file might be better than a rewrite.

 <VirtualHost *:80>
DocumentRoot /www/alpha.com/
ServerName www.alpha.com
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /www/beta.com
ServerName www.beta.com
</VirtualHost>