.htaccess规则在子文件夹中的root和core php中有cakephp

时间:2016-04-11 17:08:47

标签: php .htaccess cakephp

我有一个cakephp应用程序作为根文件夹,.htaccess编写如下

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^$ app/webroot/ [L]
    RewriteRule (.*) app/webroot/$1 [L]
</IfModule>

现在我想要的是它的子文件夹中的核心php应用程序,但是.htaccess给我带来了麻烦。 写.htaccess的最佳方式是什么,这样两者都可以。

2 个答案:

答案 0 :(得分:2)

最简单的解决方案是简单地在webroot目录中放置您想要访问的内容,例如,对于网址http://example.com/other/thing.php,请不要这样做:

html/
    app
        webroot/
    other/
         thing.php

这样做:

html/
    app
        webroot/
            other/
                thing.php

答案 1 :(得分:-1)

我会使用RewriteMap Directive而不是直接尝试从PHP代码编辑.htaccess。 请检查此answer