2011-04-06 130 views
5

我有一個wordpress網站安裝在目錄「wp」。我想保留在該文件夾中用於維護目的。 Wordpress提供了爲固定鏈接創建htaccess的選項。你可以在下面看到這個代碼(它工作)。htaccess重寫Wordpress子目錄與永久根

我想要的是一個重寫過程 - 訪問者 - 該網站似乎是在根。我必須改變重寫基地,但那不起作用。

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /wp/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /wp/index.php [L] 
</IfModule> 

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /wp/ 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /wp/index.php [L] 
</IfModule> 

回答

1

你會想到什麼看法:

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^.*$ /wp/index.php [L] 


RewriteCond %{REQUEST_URI} !^/wp/.*$ 
RewriteRule ^(.*)$ /wp/$1 [L] 

你重寫所有不存在的東西/wp/index.php,和所有非/ WP /文件到/ WP /當量文件。所以,如果你的index.php它其實/wp/index.php在儀表板

+0

我試過了,但沒有奏效。我自己找到了解決方案,稍後會發布。 – SPRBRN 2011-04-06 18:32:10

10

1),進入設置 - >通用並確保
一)WordPress的目錄 - >http://mydomain.com/wp
B)網站地址 - >http://mydomain.com

2)從子目錄移動你的index.php到根(MOVE,不只是複製)

3)編輯您的index.php閱讀

/** Loads the WordPress Environment and Template */ 
require('./wp/wp-blog-header.php'); 

其中 「WP」 是你的子目錄

4)刪除子目錄

5任.htaccess文件)這根

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 
# END WordPress 

添加到您的.htaccess在這種設置中,你的WordPress安裝將位於/ wp /目錄中。訪問者將使用http://mydomain.com訪問您的網站。祝你好運。

+0

最近有人試過這種方法嗎? – 2016-12-21 17:49:58