I hope I will find a help here. I have a quite complex MVC driven application.
Here how it works:
these are my directories
- / - (/dispatcher.php as mvc1 app bootstrap)
- /mvc2 - (/mvc2/dispatcher.php as mvc2 app bootstrap)
- /mvc3 - (/mvc3/开发者_运维知识库dispatcher.php as mvc3 app bootstrap)
all 3 are accesible under one domain example.com then
- example.com/ - is 1st MVC application
- example.com/mvc2 - is 2nd application
- example.com/mvc3 is a 3rd application.
So far everything is working nicely on .htaccess files (in each mvc folder) which have following code inside:
RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css|htc|swf|html|xml)$ dispatcher.php
code is correct my problem is that I would like to move it into vhost.conf file or httpd.conf which is loaded into memory at Apache startup and get rid of all .httaccess to boost up Apache performance.
the current solutions its working correctly because each .htaccess is overwritting its parent directory one, which I can't have to working in vhost.conf
So far I have tried to move it into directive but without success. Any ideas ?
many thanks for help.
cheers
Try this rule:
RewriteEngine on
RewriteCond %{REQUEST_URI} !.*\.(js|ico|gif|jpg|png|css|htc|swf|html|xml)$
RewriteRule ^(/mvc2|/mvc3)?/ $1/dispatcher.php
That should redirect requests of /mvc2/…
or /mvc3/…
to the corresponding dispatcher.php. And only if the URL path does start with neither /mvc2/…
nor /mvc3/…
it’s redirected to the dispatcher.php in the root directory.
精彩评论