2011-04-06 134 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