2015-06-25 143 views
1

在我的服務器的根上,我用htaccess的codeigniter。我已經在codeigniter的子文件夾(例如應用程序,配置文件)中創建了一個wp /文件夾,其中我放置了所有wordpress文件。現在,當有人類型Codeigniter - htaccess重寫隱藏wordpress文件夾

www.abc.com 

我重定向他

www.abc.com/wp/ 

,但我想隱藏在url WP。如何在不修改當前文件結構的情況下實現這一目標?我想讓wordpress成爲我網站的前臺,codeigniter是我網站的後端。下面的文件結構如下所示:

enter image description here

+0

爲什麼不修改你的Codeigniter路由? – CodeGodie

+0

你能複製和粘貼你的命令提示符'樹'文件結構 - 命令在這裏?這將使我們更好地瞭解您的目錄中實際存在的內容。 – CodeGodie

+0

是的PLZ指南,在這種情況下,我如何修改CI路由。 –

回答

0

在你的根目錄下,創建具有以下代碼的的.htaccess。這將把你所有的http請求映射到/ wp /目錄。

# ==>Initializaion… 
Options -Indexes 
Options +FollowSymLinks 
RewriteEngine On 
RewriteBase/

# ==>Without this line, your /wp/ directory may become visible sometimes 
DirectorySlash Off 

# ==>Map everything to your /wp/ directory 
RewriteRule (.*) /wp/$1 [L] 

您還想從URL中隱藏/ wp/directoy。爲此,創建你的/ wp /目錄另一個的.htaccess和寫入以下行:

# ==>Initializaion… 
Options +FollowSymLinks 
RewriteBase/

# ==>Set default file 
DirectoryIndex index.php 

#==> If the requested resource is NOT a file, or the URL contains 「/wp/」 anywhere in it, 
# then serve the default file instead 
RewriteCond %{REQUEST_FILENAME} !-f [OR] 
RewriteCond %{THE_REQUEST} /wp/ 
RewriteRule .* index.php [L] 

如果有人類型「/ WP /」,在地址欄的任何地方,他們不會看到它是什麼。相反,他們會看到你的主頁。

您可能需要調整代碼以滿足您的要求。