I have a symfony 2 website which requires all urls to be re-written to the document index.
Additionally, there are a number of completely independent “micro sites” which just run out of their own sub-folders in the web directory. I need to add re-write exceptions for any urls that point to the microsite sub folders
This is my .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/(microsite1|microsite2|microsite3)(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ %{document_index} [QSA,L]
</IfModule>
This works for everything except .php files within the microsite folders, i.e:
- http://www.domain.com/microsite1/index.html —works (displays index.html)
- http://www.domain.com/microsite2/ —works (displays index.php)
- http://www.domain.com/microsite2/contact.php — doesn’t work (displays symfony route not found error)
aditionally:
- http://www.domain.com/microsite2/images/ —successfully displays directory listing
- http://www.domain.com/microsite2/images/image.jpg — successfully displays image
You might need to change your apache config to something like this:
Paying close attention to the last RewriteRule…