开发者

How to run CakePHP app from subdirectory

开发者 https://www.devze.com 2022-12-31 05:20 出处:网络
Using CakePHP 1.3, I have the following layout: /srv/www/_cakephp13/ /app/ /cake/ /plugins/ /vendors/ etc...

Using CakePHP 1.3, I have the following layout:

/srv/www/_cakephp13/
    /app/
    /cake/
    /plugins/
    /vendors/
    etc...

/srv/www/htdocs/  
    /cake_app/
    /other-dir/

... where htdocs is the public directory, and I have moved webroot of my app to be cake_app above... Which appears to be almost working. (After customizing webroot's index.php).

When I access http://devserver/cake_ap开发者_JAVA百科p/, I am able to see the default "Home" page controller/view (which I have customized, so that appears to be working).

But when I access http://devserver/cake_app/controller/view I am receiving 404 errors.

Is is possible to run a Cake App in a sub-directory of a site root? How can I get this working?

Ideally, I don't want to edit Apache conf's... If I can fix this with Cake configuration or htaccess files, I'll be much happier.


You should verify that .htaccess is being run and that the rewrite module is on and working.


You will need to have mod_rewrite enabled on Apache. To check if it's on, make a page that just does this:

echo phpinfo():

Grep on the text "loaded modules". Make sure mod_rewrite is listed there. If it's not, you can either add it to apache's configuration, or you may need to install it (depending on your original installation method and whether you included that module).

If you can't get mod_rewrite running, you can still use cake without it (the URL will just look like index.php/controller/action/etc). Check out http://book.cakephp.org/view/333/A-Note-on-mod_rewrite for more info. Specifically,

If you don't want or can't get mod_rewrite (or some other compatible module) up and running on your server, you'll need to use Cake's built in pretty URLs. In /app/config/core.php, uncomment the line that looks like:

Configure::write('App.baseUrl', env('SCRIPT_NAME'));

0

精彩评论

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