admin管理员组文章数量:1130349
I'm not sure if this is specific to my site or not, but if anyone knows how to override this behavior, that would be most appreciated! I have WordPress installed in the root directory of my server. There is also an unrelated sub-directory we'll call 'restricted-dir'. I have added an .htaccess file inside that directory with the following code:
Deny from all
Without that command, if a user visits www.my-domain/restricted-dir/ it would list all contents. I would like the user to receive the server's typical 403 Forbidden message, but instead WordPress kicks in and directs the user to my 404 page on my website.
Is there anything I can do to make the 403 page show up instead of the 404 page along with my entire WordPress install?
I'm not sure if this is specific to my site or not, but if anyone knows how to override this behavior, that would be most appreciated! I have WordPress installed in the root directory of my server. There is also an unrelated sub-directory we'll call 'restricted-dir'. I have added an .htaccess file inside that directory with the following code:
Deny from all
Without that command, if a user visits www.my-domain/restricted-dir/ it would list all contents. I would like the user to receive the server's typical 403 Forbidden message, but instead WordPress kicks in and directs the user to my 404 page on my website.
Is there anything I can do to make the 403 page show up instead of the 404 page along with my entire WordPress install?
Share Improve this question asked Oct 30, 2017 at 18:34 EricaErica 1715 bronze badges 3 |2 Answers
Reset to default 0Thinking on it for a minute, I suppose it has something to do with the rewrite rules from the WP .htacces is kicking in and rewriting the request to WP. It doesn't totally make sense to me, because WP's rewrite rules actually ignore directories, and I cannot reproduce it with a quick test, but there might be other factors at play in your environment.
Adding
RewriteEngine On
RewriteRule ^restricted-dir - [F,L]
in the WP .htaccess before the WordPress Rewrite Rules should have the same result, denying access to restricted-dir with a 403 response.
This question is old but in case anyone else comes across with the same problem, I found the answer in this ticket:
https://wordpress.stackexchange/a/20274/31889
(For me solution #3 was the ticket, but I also have the first two in place so maybe it was a combination.)
I'm not sure if this is specific to my site or not, but if anyone knows how to override this behavior, that would be most appreciated! I have WordPress installed in the root directory of my server. There is also an unrelated sub-directory we'll call 'restricted-dir'. I have added an .htaccess file inside that directory with the following code:
Deny from all
Without that command, if a user visits www.my-domain/restricted-dir/ it would list all contents. I would like the user to receive the server's typical 403 Forbidden message, but instead WordPress kicks in and directs the user to my 404 page on my website.
Is there anything I can do to make the 403 page show up instead of the 404 page along with my entire WordPress install?
I'm not sure if this is specific to my site or not, but if anyone knows how to override this behavior, that would be most appreciated! I have WordPress installed in the root directory of my server. There is also an unrelated sub-directory we'll call 'restricted-dir'. I have added an .htaccess file inside that directory with the following code:
Deny from all
Without that command, if a user visits www.my-domain/restricted-dir/ it would list all contents. I would like the user to receive the server's typical 403 Forbidden message, but instead WordPress kicks in and directs the user to my 404 page on my website.
Is there anything I can do to make the 403 page show up instead of the 404 page along with my entire WordPress install?
Share Improve this question asked Oct 30, 2017 at 18:34 EricaErica 1715 bronze badges 3-
Are you using apache 2.2 or 2.4? For 2.2, your try should work imho, for 2.4, you should use
Require all denied, see also the upgrade guide. – janh Commented Oct 30, 2017 at 18:39 - It's only 2.2 so I would have thought so too, unless something else is overriding it. I had hoped it was a WP thing that could be overwritten. – Erica Commented Oct 30, 2017 at 18:48
- Changing my WordPress theme did not change the results. I wanted to check since it had custom 404 settings. – Erica Commented Oct 30, 2017 at 18:49
2 Answers
Reset to default 0Thinking on it for a minute, I suppose it has something to do with the rewrite rules from the WP .htacces is kicking in and rewriting the request to WP. It doesn't totally make sense to me, because WP's rewrite rules actually ignore directories, and I cannot reproduce it with a quick test, but there might be other factors at play in your environment.
Adding
RewriteEngine On
RewriteRule ^restricted-dir - [F,L]
in the WP .htaccess before the WordPress Rewrite Rules should have the same result, denying access to restricted-dir with a 403 response.
This question is old but in case anyone else comes across with the same problem, I found the answer in this ticket:
https://wordpress.stackexchange/a/20274/31889
(For me solution #3 was the ticket, but I also have the first two in place so maybe it was a combination.)
本文标签: 404 errorWhy does my WordPress show a 404 message for 403 forbidden directories
版权声明:本文标题:404 error - Why does my WordPress show a 404 message for 403 forbidden directories? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749245145a2338750.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


Require all denied, see also the upgrade guide. – janh Commented Oct 30, 2017 at 18:39