I have this config for a particular virtual host
- Code: Select all
NameVirtualHost xxx.subdomain.domain.com:80
<VirtualHost xxx.subdomain.domain.com:80>
ServerName xxx.subdomain.domain.com
ServerAlias *.subdomain.domain.com
UseCanonicalName Off
DocumentRoot "/path/to/files"
VirtualDocumentRoot /path/to/files/%1
<Directory "/path/to/files/xxx">
Options +FollowSymLinks
Options Includes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
This makes possible to use virtual hosts created on the fly
xxx.subdomain.domain.com -> /path/to/files/xxx
yyy.subdomain.domain.com -> /path/to/files/yyy
zzz.subdomain.domain.com -> /path/to/files/zzz
And works fine.
Now, I want to create a rewrite rule, but only if the file requested doesn't exists physically on the server.
Normally, on a normal virtual host, I used this code (which worked)
- Code: Select all
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule . /path/to/files/xxx/make_the_thumbnail.php [L]
But once I put those lines in the previous code, the RewriteCond doesn't work, and the request is always redirected on make_the_thumbnail.php, even if the file requested (an image) exists.
I mean
xxx.subdomain.domain.com/folder/myfile.jpg -> /path/to/files/xxx/folder/myfile.jpg
myfile.jpg exists, but apache doesn't find it
Here is the code I use
- Code: Select all
NameVirtualHost xxx.subdomain.domain.com:80
<VirtualHost xxx.subdomain.domain.com:80>
ServerName xxx.subdomain.domain.com
ServerAlias *.subdomain.domain.com
UseCanonicalName Off
DocumentRoot "/path/to/files"
VirtualDocumentRoot /path/to/files/%1
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule . /path/to/files/xxx/make_the_thumbnail.php [L]
<Directory "/path/to/files/xxx">
Options +FollowSymLinks
Options Includes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I suspect the RewriteCond line doesn't intercept the right filename, because of the DocumentRoot value that isn't equal to the VirtualDocumentRoot.
But how to correct it ?