I wish to host two different services on the Apache web server, obtainable through the same domain: Some kind of special Web addresses should enter in the filesystem, others ought to be handle with a Rails application.


=> should deliver /var/www/special/foo/123.txt

=> should go to Rails/Passenger

Here's my virtual host setup for that Rails application:

<VirtualHost *:80>
    ServerName mydomain.com
    ServerAlias *.mydomain.com

    DocumentRoot /var/www/mydomain/current/public

    <Directory /var/www/mydomain/current/public>
    	Options FollowSymLinks
    	AllowOverride None
    	Order allow,deny
    	Allow from all
    	ExpiresActive on
    	ExpiresDefault "access plus 1 year"
    	FileETag MTime Size

    RewriteEngine On

    # Check for maintenance file and redirect all requests
    ErrorDocument 503 /system/maintenance.html
    RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|png)$
    RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
    RewriteCond %{SCRIPT_FILENAME} !maintenance.html
    RewriteRule ^.*$	-	 [redirect=503,last]

    # Rewrite index to check for static
    RewriteRule ^/$ /index.html [QSA]

    # Rewrite to check for Rails cached page
    RewriteRule ^([^.]+)$ $1.html [QSA]

    # Deflate
    AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml application/xml application/xhtml+xml text/javascript application/x-javascript

    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

    ErrorLog /var/log/apache2/mydomain.com-error_log
    CustomLog /var/log/apache2/mydomain.com-access_log combined

Somewhere in the centre a RewriteCond/RewiteRule ought to be added, so being able to access http://mydomain.com/foo/123.txt does not go near the Rails application, however the filesystem rather.

With this I want help. It might by great if a person can can provide us a hint.

Found the answer on my own:

RewriteCond %{REQUEST_URI} ^/foo/.*$
RewriteRule ^.*$ /var/www/special/foo%{REQUEST_URI}