0

使用 CakePHP。该网站是 www.villapalmeras.co.uk。当我查看根目录时,我的链接正确显示(即http://www.villapalmeras.co.uk/public/events)。当我导航到任何其他页面时,相同的链接会显示为http://www.villapalmeras.co.uk/websites/123reg/LinuxPackage25/jo/rd/an/jordanwallwork.co.uk/public_html/domains/villalaspalmeras/公共/活动

我正在使用 123-reg 托管包,并将 villapalmeras.co.uk 域映射到位置域/villapalmeras(其根目录是我在 jordanwallwork.co.uk 的网站)。尝试编辑 .htaccesses 文件但没有成功。

我的 .htaccess 文件是:

/domains/villapalmeras/.htaccess:

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

/domains/villapalmeras/app/.htaccess:

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

/domains/villapalmeras/app/webroot/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

索引.php:

define('APP_DIR', 'app');
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__));
define('WEBROOT_DIR', 'webroot');
define('WWW_ROOT', ROOT . DS . APP_DIR . DS . WEBROOT_DIR . DS);

if (!defined('CAKE_CORE_INCLUDE_PATH')) {
    define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
}

require APP_DIR . DS . WEBROOT_DIR . DS . 'index.php';
4

3 回答 3

2

原来答案真的很简单!我需要做的就是添加RewriteBase /到所有 .htaccess 文件中,而不仅仅是根目录,然后它就可以完美运行了

于 2012-06-17T18:37:46.240 回答
0

您必须更改每个 .htaccess 并且不需要更改 index.php 或其他文件。

/domains/villapalmeras/.htaccess:

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

/domains/villapalmeras/app/.htaccess:

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

/domains/villapalmeras/app/webroot/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /app/webroot/
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
于 2013-11-11T12:52:08.533 回答
0

只是为了澄清我上面的评论,您要修改的代码可能在您的 index.php 中:

您正在寻找的代码:

/**
 * The full path to the directory which holds "app", WITHOUT a trailing DS.
 *
 */
    if (!defined('ROOT')) {
        define('ROOT', dirname(dirname(dirname(__FILE__))));
    }
/**
 * The actual directory name for the "app".
 *
 */
    if (!defined('APP_DIR')) {
        define('APP_DIR', basename(dirname(dirname(__FILE__))));
    }
/**
 * The absolute path to the "cake" directory, WITHOUT a trailing DS.
 *
 */
    if (!defined('CAKE_CORE_INCLUDE_PATH')) {
        define('CAKE_CORE_INCLUDE_PATH', ROOT);
    }

它应该更改为更像:

/**
 * The full path to the directory which holds "app", WITHOUT a trailing DS.
 *
 */
    if (!defined('ROOT')) {
        define('ROOT', DS . 'home' . DS . 'username');
    }
/**
 * The actual directory name for the "app".
 *
 */
    if (!defined('APP_DIR')) {
        define('APP_DIR', 'domain.com');
    }
/**
 * The absolute path to the "cake" directory, WITHOUT a trailing DS.
 *
 */
    if (!defined('CAKE_CORE_INCLUDE_PATH')) {
        define('CAKE_CORE_INCLUDE_PATH', 'home' . DS . 'username');
    }

当然取决于您的主机目录的结构。

于 2012-06-17T15:30:33.200 回答