开发者

Mod rewrite rules for hosting multiple projects using Zend Framework

开发者 https://www.devze.com 2023-03-17 18:01 出处:网络
I have several small projects I want to host on single virtual host using Zend Framework. The structure is:

I have several small projects I want to host on single virtual host using Zend Framework. The structure is:

    apps/
        testapp1/
          application/
          index.php,
        testapp2/
          a开发者_如何学JAVApplication/
          index.php

Document root in virtual host looks like: DocumentRoot /var/www/apps/

I need univeral mod_rewrite rule which will transform URLs like /apps/testapp1/xxx into /apps/testapp1/index.php.

Any help will be greatly appreciated as I am trying to resolve that for several hours. Thank You.


  1. If your DocumentRoot for website is /var/www/apps/, then I guess URLs would be http://www.example.com/testapp1/ajax instead of http://www.example.com/apps/testapp1/ajax. If so -- then you need to remove apps/ part from these rules.

  2. These rules need to be placed in your .htaccess into website root folder.

  3. If you already have some rules there then these new rules needs to be placed in correct place as order of rules matters.

  4. You may need to add RewriteEngine On line there if you do not have such yet.

This rule will rewrite /apps/testapp1/ajax into /apps/testapp1/index.php, no other URLs will be affected:

RewriteRule ^apps/testapp1/ajax$ /apps/testapp1/index.php [NC,QSA,L]

This rule will rewrite ALL URLs that end with /ajax into /index.php (e.g. /apps/testapp1/ajax => /apps/testapp1/index.php as well as /apps/testapp2/ajax => /apps/testapp2/index.php):

RewriteRule ^(.+)/ajax$ /$1/index.php [NC,QSA,L]

UPDATE:

This "universal" rule will rewrite /apps/testapp1/xxx into /apps/testapp1/index.php as well as /apps/testapp2/something => /apps/testapp2/index.php:

RewriteRule ^(.+)/([^/\.]+)$ /$1/index.php [NC,QSA,L]
0

精彩评论

暂无评论...
验证码 换一张
取 消