【问题标题】:htaccess - returning 404 errors on xml files?htaccess - 在 xml 文件上返回 404 错误?
【发布时间】:2017-03-23 03:54:57
【问题描述】:

我安装的 WordPress 有一个包含许多 XML 文件的目录。直到今天早上 - 这些文件都可以通过浏览器访问(我可以直接浏览它们)。但是现在 - 尝试直接从浏览器调用它们会返回 404 错误。

我很困惑,因为什么都不应该改变。我假设这很可能是 .htaccess 问题?

这是我的 htaccess:

 <Files xmlrpc.php>
 <IfModule !mod_authz_core.c>
 order deny,allow
 deny from all
 allow from xx.xx.xx.xx
 allow from xx.xx.xx.xx
 </IfModule>
 <IfModule mod_authz_core.c>
 Require ip xx.xx.xx.xx xx.xx.xx.xx
 </IfModule>
 </Files>
 # END GOTMLS Patch to Block XMLRPC Access
 # 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

(注意 - 隐藏的相关 IP 地址)

我错过了什么?

【问题讨论】:

    标签: xml wordpress apache .htaccess


    【解决方案1】:

    如果显示 404 错误,则 htaccess 文件错误。 只需将 htaccess 代码从您的代码更改为我的代码即可。

    如果您的文件位于 www.xyz.com/foldername/ 等文件夹中 因此使用以下代码。

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

    如果您的文件直接在像 www.xyz.com 这样的服务器上 因此使用以下代码

    # 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 文件,该文件位于 wp-config 文件可用的主目录中,另一个 htaccess 位于 wp-content 文件夹中。 在 wp-cotent 文件夹中创建另一个 .htaccess 文件并编写以下代码。

    #<FilesMatch "\.(?i:php)$">
    #  <IfModule !mod_authz_core.c>
    #    Order allow,deny
    #    Deny from all
    #  </IfModule>
    #  <IfModule mod_authz_core.c>
    #    Require all denied
    #  </IfModule>
    #</FilesMatch>
    

    在此之后检查您的 wp-admin,它不会显示 404 错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-25
      • 2021-03-02
      • 1970-01-01
      • 2015-05-24
      • 2015-04-14
      • 1970-01-01
      • 1970-01-01
      • 2013-06-14
      相关资源
      最近更新 更多