简体   繁体   中英

using index.php to make 404 page show up instead

I am using a hosted wordpress site.

I don't like the idea of people accessing my wp-content folder, so I have added in the blank index.php in there.

But I am not satisfied with this solution. To go a step further, is it possible for me to rewrite this index.php such that it does not just show a blank page, I want it to show a 404 page which I already have created. What code should I put in there?

you could put this in your index.php

<?php

header("HTTP/1.1 404 Not Found");

?>

Thanks all, in the end this is what I did, I added

Options -Indexes
ErrorDocument 403 /

to my .htaccess file

so when someone tries to access my plugin folder for eg. mysite.com/wp-content/plugins/abc-plugin , my 404 page appears. However when I go to mysite.com/wp-content or mysite.com/wp-content/plugins, a blank page still shows up.

But I guess its better than nothing, because when I first attempted using only

 Options -Indexes

in my .htaccess, and I tried to access the plugin folder for eg. mysite.com/wp-content/plugins/abc-plugin , a 403 page with my hosting logo shows up, which I found it unsightly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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