开发者

Custom PHP MVC Framework: How to ensure locational compatibility with .htaccess?

I am developing a PHP MVC framework based CMS system.

I have the following directory structure on my WAMP server:

c:/<webroot>/application/ (contains all Ms Vs and Cs)
c:/<webroot>/config/ (contains application.ini)
c:/<webroot>/public/ (contains /img, /js, & /css)
c:/<webroot>/index.php (entry point of MVC)
c:/<webroot>/.htaccess

.htaccess contains:

RewriteEngine On
Rewrite开发者_JAVA百科Base /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

There are no .htaccess files anywhere else in the system.

the .htaccess rules are intended to be implemented to rewrite the URL with Zend-framework style http://HTTP_HOST/controller/action/key/value/.../key/value/ style URLS

As far as I can tell, this is working pretty well when the MVC is sitting at the root of the web host.

As soon as I go one folder deep, however, everything falls apart: Say for instance, I want a MVC website to be hosted from the root, and its MVC-based CMS hosted on level deep (/admin/). Having the .htaccess file above seems to bounce all requests to the CMS back to the root site... Do I need a different .htaccess rule for each folder? Is there a rule that can be written to ignore requests to the CMS by the root .htaccess file?

Thanks!


.htaccess rules are enforced based on the directory hierarchy. If no .htaccess rule is located within a sub-directory, then it will abide by the rules defined in the parent directory (or higher until an .htaccess file is found). If an .htaccess file is located within a sub-directory, the rules enforced are a cumulation of rules already defined plus any superseding rules that are defined.

In your case, you could write rules within your root .htaccess to deal with an admin sub-directory. However, it is probably easier and more clear to define a new .htaccess file within the admin sub-directory.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜