2015-04-03 23 views
1

我有一個完美工作的網站作爲我的虛擬主機(/ public_html)的根,但我最近買了一個新域名並將它停放在那裏,所以我需要一個子目錄(/ public_html/newdomaindir)。將CodeIgniter網站移動到子文件夾

現在我需要將整個網站移動到一個子文件夾(/ public_html /網站),我很難適應.htaccess文件。

這是我的老工作的.htaccess文件時,它是根:

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^website.org$ 
RewriteRule ^/?$ "http\:\/\/www\.website\.org\/" [R=301,L] 

#SetEnvIfNoCase Host ^www\.website\.org$ require_auth=true 

RewriteCond $1 !^(index\.php|images|css|robots\.txt|js|icons|files|fonts|extplorer) 
RewriteRule ^(.+)$ /index.php?/$1[L,QSA] 

而且現在的虛擬主機提供商的支持表明,我有這個.htaccess文件爲根,以重定向流量。

RewriteEngine On 
Options +FollowSymlinks 
RewriteCond %{HTTP_HOST} website.org$ 
RewriteCond %{REQUEST_URI} !website/ 
RewriteRule ^(.*)$ website/$1 

但是,呃......它沒有像預期的那樣工作。我的網站壞了。

我應該使用不同的方法,也許要求支持人員更改我的網站的document_root?我應該更改子文件夾.htaccess文件中的任何內容嗎?

任何幫助,非常感謝。謝謝。

+0

您是否嘗試通過更改CI配置文件中的'base url' – 2015-04-03 13:35:07

+0

這應該不會改變。它仍然是'$ config ['base_url'] \t ='http://www.website.org/';' – 2015-04-03 13:38:26

+0

請嘗試更改'$ config ['base_url'] \t ='http://www.website .org /';'到'$ config ['base_url'] ='http://www.website.org/website';'與原始.htaccess – 2015-04-03 13:42:37

回答

2

不是我的最強技能,但我會嘗試修改以前的.htaccess以如下形式:

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^website.org$ 
RewriteRule ^/?$ "http\:\/\/www\.website\.org\/" [R=301,L] 

# not sure what about this 
#RewriteCond $1 !^website\/(index\.php|images|css|robots\.txt|js|icons|files|fonts|extplorer) 
RewriteRule ^$ website/ [L] 
RewriteRule ^(.+)$ website/index.php?/$1[L,QSA] 

如果不工作,也許你會發現一些線索this SO answer

+0

瞭解它與RewriteBase的工作,而不是改變RewriteRules – 2015-04-03 14:27:15

相關問題