繁体   English   中英

在子目录上安装Wordpress时出现403错误

[英]403 error on wordpress install on subdirectory

我有一个具有以下结构的网站:

/public_html
    /main site content (html content mostly)
    /.htaccess (1)
    /secret (dir)
        /wp (dir)
            /a wordpress install
            /.htaccess (2)

/ secret / wp /是要移至wordpress解决方案的开发站点。 这是我在新网站上工作的地方。

当我尝试查看新站点时,根.htaccess导致403禁止错误。 我知道这是因为从服务器删除它可以解决此问题。

问题是,它正在为我重写一些重要的文件扩展名,否则我的主站点将中断。

htaccess(1)

<Files ~ "^\.(htaccess|htpasswd)$">
deny from all
</Files>

DirectoryIndex index.html

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteRule ^(wp-admin)($|/) - [L] # You don't want to mess with WordPress 
 RewriteRule ^/secret/wp/ - [L]
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME}\.html -f
 RewriteRule .* $0.html

 # browser requests html
 RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.html
 RewriteRule ^/?(.*)\.html$ /$1 [L,R=301]

 # check to see if the request is for a html file:
 RewriteCond %{REQUEST_FILENAME}\.html -f
 RewriteRule ^/?(.*)$ /$1.html [L]
</IfModule>

Redirect 301 /shop.html https://mydomain.myshopify.com/

添加行“ RewriteRule ^ / secret / wp /-[L]”是寻找此问题的解决方案的结果,但似乎没有任何作用。

我的其他.htaccess似乎根本没有触发。 为了清楚起见,我将其发布:

.htaccess(2)

# BEGIN WordPress
<IfModule mod_rewrite.c>

    RewriteEngine On

    RewriteBase /secret/wp/

    RewriteRule ^index\.php$ - [L]

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule . /secret/wp/index.php [L]

    # Fix 403 errors on existing directories; WordPress overrides.
        RewriteCond %{REQUEST_URI} ^/secret/wp/
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule . /index.php [L]

</IfModule>
# END WordPress

我不知所措。 我不能只是删除.htaccess文件,否则整个站点都将中断,但是我似乎无法弄清楚如何停止403错误。 我很确定这是由于重写规则所致,但似乎并没有像预期的那样停止该目录。

任何帮助将不胜感激。

我认为您可以将其尝试到您的.htaccess文件中

RewriteCond %{REQUEST_FILENAME} -f [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^ - [L]

RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]

RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]

RewriteRule . index.php [L]

找到了答案。 我花了一周的时间在所有可能的论坛上进行挖掘和测试,但是最终(删除整个wp安装并重新安装到一个干净的目录之后),我找到了解决所有问题的最简单答案:

我必须编辑.htaccess文件以允许“ index.php”作为有效的默认索引页面。

我的域顶层的.htaccess文件只有以下一行:DirectoryIndex index.html

我只需要将其更改为DirectoryIndex index.html index.php

然后一切正常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM