简体   繁体   中英

how to? mod_rewrite in different .htaccess files per folder move into vhost.conf - mvc

I hope I will find a help here. I have a quite complex MVC driven application.

Here how it works:

these are my directories

  1. / - (/dispatcher.php as mvc1 app bootstrap)
  2. /mvc2 - (/mvc2/dispatcher.php as mvc2 app bootstrap)
  3. /mvc3 - (/mvc3/dispatcher.php as mvc3 app bootstrap)

all 3 are accesible under one domain example.com then

  1. example.com/ - is 1st MVC application
  2. example.com/mvc2 - is 2nd application
  3. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM