0

I have a web application that has "pretty urls". The .htaccess file there looks like this:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([a-z0-9]+)(/)?([a-z0-9]+)?$ /home/user/domains/domain1.com/public_html/sites/index.php?site=$1&page=$3 [QSA]

So when I enter domain1.com/site/page it actually shows me domain1.com/index.php?site=site&page=page. This works fine.

BUT

I have another domain, let's say domain2.com. I have it in the same account in the DirectAdmin. When I enter the ftp account and go to domains/ I see there both domain1.com and domain2.com.

I want to force domain2.co.il to show domain1.com/index.php?site=domain2

I placed the same .htaccess file (with a minor change of the site parameter) in the public_html of domain2.com. The result is 404 error.

So the question is: How to make it work the way I want?


I also read the following posts, but I can't seem to find use out of them. Maybe I just don't understand how:

Community
  • 1
  • 1
Dimdum
  • 322
  • 2
  • 15
  • Do you have access to the `.conf` files, of apache? or is the `mod_proxy` module enabled? or can you enable `mod_proxy`? else not possible. – ThinkingMonkey Feb 09 '12 at 18:06
  • I think I can gain access to both of those features. But how does this help me? – Dimdum Feb 14 '12 at 17:39

1 Answers1

0

Assuming your folder structure looks like

/domains
    /domain1.com
    /domain2.com

You can do this using the following rule:

RewriteRule ^(.*)? ../domain1.com/index.php?site=domain2&q=$1 [L]

There's a good chance you'll have to use PHP's chdir() function to get it operating in the proper directory, which you can do by passing chdir() the PHP magic constant __DIR__.

Dan Ambrisco
  • 865
  • 7
  • 13
  • Both `RewriteRule ^(.*)? ../domain1.com/public_html/sites/index.php?site=elizur&q=$1 [L]`, and `RewriteRule ^(.*)? ../../domain1.com/public_html/sites/index.php?site=elizur&q=$1 [L]` (I think the `public_html` causes it to be 2 levels up) result in a `400` error (`Bad Request. Your browser sent a request that this server could not understand.`) – Dimdum Feb 14 '12 at 17:36
  • That's rather odd. The rule above works fine on my server. It may have to do with the server's configuration in that case. It's especially odd since you already have FollowSymLinks turned on. – Dan Ambrisco Feb 15 '12 at 20:34
  • Can you think of any configuration that might be blocking this? – Dimdum Feb 16 '12 at 17:02
  • Not immediately. If anything, I might expect a Too Many Redirects error, so this is rather confusing. I'll see if I can't trip the error on my own server when I have time. – Dan Ambrisco Feb 17 '12 at 22:53