Setting up apache rewrite rule to only forward if in a directory
Posted
by wooowoopo
on Server Fault
See other posts from Server Fault
or by wooowoopo
Published on 2009-10-07T15:35:06Z
Indexed on
2010/04/26
17:04 UTC
Read the original article
Hit count: 246
apache
|virtualhosts
Hi, I currently have a site setup with the following in httpd.conf:
<VirtualHost x.x.x.x:80>
ServerName testsite
ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType text/css A2592000
ExpiresByType application/x-javascript A1
ExpiresByType text/javascript A1
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript text/javascript
DocumentRoot /usr/local/www/apache22/data/thesite/trunk
RewriteEngine On
RewriteRule !\.(htc|js|tiff|gif|css|jpg|png|swf|ico|jar|html|doc|pdf|htm|xml)$ %{DOCUMENT_ROOT}/../platform.php [L]
</VirtualHost>
Where x.x.x.x is my IP.
At the moment it forwards anything which is not in the set (htc|js|tiff|gif|css|jpg|png|swf|ico|jar|html|doc|pdf|htm|xml) to platform.php
How htp://x.x.x.x/phpmyadmin to also forward. Would it be possible to only perform this rewrite conidtion if I am in a subdirectory. Eg. http://x.x.x.x/projectone So htp://x.x.x.x/projectone/login would direct to the platform.php
Thanks
© Server Fault or respective owner