htaccess redirect - wordpress代码冲突

时间:2014-08-30 06:16:35

标签: wordpress apache .htaccess mod-rewrite

我想知道某个善良的灵魂是否可以帮助我。

我在一个名为'wp'的子目录中构建了一个新的WordPress站点。而不是移动所有内容(我不完全了解该怎么做)我想简单地重定向主页面,即http://www.example.com指向http://www.example.com/wp/,并从所有子页面加载所有页面minues地址行中的/ wp /。

根据我的网络主机的说明,我已将此重定向代码添加到.htacess文件中:

# Justhost.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 example.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?example.com
$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/wp/
# Don't change these line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /wp/$1
# Change example.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.)?example.com$
RewriteRule ^(/)?$ wp/index.php [L]

然而,这不起作用,我的网络主机,谁不是很有帮助,告诉我WordPress生成的一些现有代码是冲突的。这是.htaccess文件中的现有代码:

DirectoryIndex index.html index.shtml index.xhtml index.wml index.perl index.pl index.plx index.ppl index.cgi index.jsp index.js index.jp index.php4 index.php3 index.php index.phtml index.htm home.htm default.htm index.fcgi default.html
# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
    order deny,allow
    deny from all
    allow from all
</Limit>
<Limit PUT DELETE>
    order deny,allow
    deny from all
</Limit>
AuthName zsr-art.org.uk
AuthUserFile /home/zsrarto1/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/zsrarto1/public_html/_vti_pvt/service.grp

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

我正在使用固定链接,我想知道这是否会导致问题。有人可以告诉我冲突在哪里以及如何解决?

1 个答案:

答案 0 :(得分:1)

RewriteBase /wp/.htaccess中的<IfModule mod_rewrite.c> RewriteEngine On RewriteBase /index.php/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php/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 . index.php [L]
</IfModule>

这一个

{{1}}