2012-06-17 116 views
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/public/events.htaccess/url重写问题

我使用的是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> 

/域/ 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'; 
+0

您可以从index.php发布ROOT,APP_DIR和CAKE_CORE_INCLUDE_PATH吗?如果这些配置正确,你就不需要搞乱.htaccesses。 – swiecki

回答

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'); 
    } 

的结构当然,根据你的主机目录。

+0

我真的想要这个,但你的代表点是777!我不能! – Adi

+0

不要这样做!我将失去权限!更不用说对我的运气产生不利影响了。 – swiecki

+0

谢谢,我甚至没有意识到该文件中有可配置的设置!我会看看,但我也包括了目前的设置,以防万一你可以发现问题 –

2

原来的答案很简单!我需要做的只是将RewriteBase /添加到所有的.htaccess文件,而不仅仅是根,然后它完美地工作

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>