cakephp inside a subdirectory

前端 未结 3 395
刺人心
刺人心 2021-01-27 08:38

I have a problem with cakephp, I can\'t find a way to get cakephp working in a subdirectory. I have a webpage that resides at www.example.com and I want to have cak

相关标签:
3条回答
  • 2021-01-27 09:15

    Did you read this page in the book and make the appropriate changes in /app/webroot/index.php?

    Edit:

    The problem is that when I go to www.example.com/cake it requests a CakeController and has no stylesheets loaded.

    This seems to indicate that you have the wrong .htaccess in your site's root (www, htdocs ,public_html or whatever) as it's trying to process the request into the CakePHP structure.

    It should not look like this

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

    Why don't you make life easy for yourself and put CakePHP in the root and move the page(s) that reside at www.example.com into app/webroot. That way it'll behave exactly as you want, i.e:

    www.example.com/staticPage.html - displays the static page.

    www.example.com/users - displays the users index

    Files in webroot are served exactly as if they were in the site's root. Think of the css and javascript files.

    0 讨论(0)
  • 2021-01-27 09:17

    Most likely your mod_rewrite is not enable in Apache on your hosting account. Check with your host. Another possible problem described below:

    Did you change the paths in webroot/index.php?

    You need to adjust the paths in that file to point to the Cake core files folder based on your hosting providers directory path.

    For example,

    if (!defined('CAKE_CORE_INCLUDE_PATH')) { 
        define('CAKE_CORE_INCLUDE_PATH', 'home' . DS .'w3dev' . DS . 'public_html' . DS . 'clients' . DS . 'folderName' . DS . 'remote' . DS . 'v1.1' . DS .  'cake'); 
    }
    

    And

    if (!defined('APP_DIR')) {
        define('APP_DIR', basename(dirname(dirname(__FILE__))). DS . 'v1.1' . DS . 'app'); 
    }
    

    The above all depends on your directory on your hosting server account. As your host for your root path data, so you can point it accordingly.

    0 讨论(0)
  • 2021-01-27 09:24

    I'm not familiar with Cake, but it is almost certainly some sort of path issue. Verify that the path to your stylesheets is accurate.

    I know that some frameworks will use a base_url() function(or something similarly named) that returns a config value, you should check your config to ensure that the base URL is set properly.

    0 讨论(0)
提交回复
热议问题