admin管理员组文章数量:1328610
I'm looking to force a 403 access denied response for an xml file in a directory outside of the default Wordpress install.
The url I'm trying to force the 403 response on looks like this mydomain/autodiscover/autodiscover.xml
I've tried modifying the default Wordpress htaccess file by adding a line to ignore the custom directory but it doesn't seem to work. When visiting the url I get a 404. I did create the directory and xml file and pushed them to our server.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(autodiscover)($|/) – [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
<Files ~ "\.(xml)$">
deny from all
</Files>
Wondering if anyone has every run into this before and if they found a solution. My end goal would be to just force the 403 on the one file so my xml sitemaps don't get blocked as well.
Thanks in advance.
I'm looking to force a 403 access denied response for an xml file in a directory outside of the default Wordpress install.
The url I'm trying to force the 403 response on looks like this mydomain/autodiscover/autodiscover.xml
I've tried modifying the default Wordpress htaccess file by adding a line to ignore the custom directory but it doesn't seem to work. When visiting the url I get a 404. I did create the directory and xml file and pushed them to our server.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(autodiscover)($|/) – [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
<Files ~ "\.(xml)$">
deny from all
</Files>
Wondering if anyone has every run into this before and if they found a solution. My end goal would be to just force the 403 on the one file so my xml sitemaps don't get blocked as well.
Thanks in advance.
Share Improve this question asked Jul 15, 2020 at 16:28 brandozzbrandozz 8121 gold badge14 silver badges27 bronze badges2 Answers
Reset to default 0So to restate your question you want mydomain/autodiscover/autodiscover.xml
to produce a 403, and your Wordpress installation is at mydomain/
?
Then this should do it to match that specific file only:
RewriteRule ^autodiscover/autodiscover.xml - [R=403,NC,L]
The fix that worked was adding an htaccess file to the directory with the line below
ErrorDocument 403 default
本文标签: htaccessForce a 403 response to xml file in Wordpress
版权声明:本文标题:htaccess - Force a 403 response to xml file in Wordpress 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742257460a2441890.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论