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 の私の Web サイトです)。.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>

index.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

答えは実にシンプルでした。ルートだけでなく、すべての .htaccess ファイルに追加RewriteBase /するだけで、完全に機能しました

于 2012-06-17T18:37:46.240 に答える
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 に答える
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 に答える