Sunday, 18 August 2013

Apache configuration - rewrite rule for all virtual hosts

Apache configuration - rewrite rule for all virtual hosts

I have the following configuration with 2 virtual hosts on my Apache:
www.domain.com and res.domain.com. The first one is open the second is
limited to registred users.
<VirtualHost *:80>
ServerName www.domain.com
DocumentRoot /website/www
<Directory "/website/www">
Options FollowSymLinks
AllowOverride All
RewriteEngine On
RewriteCond %{REQUEST_URI} !api/dispatch\.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^api/.*$ api/dispatch.php [L,QSA]
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName res.domain.com
DocumentRoot /website/res
<Directory "/website/res">
Options FollowSymLinks
AllowOverride All
AuthType Basic
AuthUserFile /website/res/users.sec
<Limit GET POST>
Require valid-user
</Limit>
</Directory>
</VirtualHost>
I would like to serve all the calls http://res.domain.com/api/* exactly as
if they were http://www.domain.com/api/*. No authentication and same
behavior...
Important: I don't want my users see a redirect...
I need help because I tried so many things but no success.

No comments:

Post a Comment