0
我目前已將我的主域名從根目錄重定向到子目錄。由於每次我使用cakePHP編寫url或獲取當前的url,它都會顯示子目錄。通過mod_rewrite將域名重定向到suddirectory,但cakePHP正在搞亂地址
例如: 如果我在主頁(http://example.com),然後用蛋糕的$this->url
它將返回/ mysubdirectory/
這裏是我使用.htaccess文件(當然修改爲適合我的需要)在我的根目錄中重定向到一個子目錄。
# Hostmonster.com
# .htaccess main domain to subdirectory redirect
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.
# Do not change this line.
RewriteEngine on
# Change yourdomain.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subdirectory/
# Don't change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /subdirectory/$1
# Change yourdomain.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by/then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
RewriteRule ^(/)?$ subdirectory/index.php [L]
我覺得我需要修改.htaccess文件在我的側面CakePHP的應用程序忽略子目錄,但我不能確定如何。
感謝您的回覆......我剛剛嘗試過,這是一個不行。 – Paramount 2011-06-02 18:35:28
我會從默認的.htaccess開始,然後在下一步更改重寫基準,如上所示。我不認爲它的壞消息是要改變別處的路徑 – alexdd55 2011-06-03 06:39:29