admin管理员组

文章数量:1122833

I'm trying to find the full path of my 404.php file. I thought it would be like this:

ErrorDocument 404 /index.php?error=404

The reason for this is because I am trying to redirect non-IP permitted people to 404.php page using the .htaccess rule (written below)

My WordPress is at the root level of the domain. 404.php doesn't load however...

Here is the .htaccess rule I have tried to get working:

ErrorDocument 401 /index.php?error=404 ErrorDocument 403 /index.php?error=404

<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_URI} ^(.*)?wp-login\.php(.*)$ [OR] RewriteCond %{REQUEST_URI} ^(.*)?wp-admin$
RewriteCond %{REMOTE_ADDR} !^IP Address One$
RewriteCond %{REMOTE_ADDR} !^IP Address Two$
RewriteCond %{REMOTE_ADDR} !^IP Address Three$ RewriteRule ^(.*)$ - 
[R=403,L] </IfModule>

I'm trying to find the full path of my 404.php file. I thought it would be like this:

ErrorDocument 404 /index.php?error=404

The reason for this is because I am trying to redirect non-IP permitted people to 404.php page using the .htaccess rule (written below)

My WordPress is at the root level of the domain. 404.php doesn't load however...

Here is the .htaccess rule I have tried to get working:

ErrorDocument 401 /index.php?error=404 ErrorDocument 403 /index.php?error=404

<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_URI} ^(.*)?wp-login\.php(.*)$ [OR] RewriteCond %{REQUEST_URI} ^(.*)?wp-admin$
RewriteCond %{REMOTE_ADDR} !^IP Address One$
RewriteCond %{REMOTE_ADDR} !^IP Address Two$
RewriteCond %{REMOTE_ADDR} !^IP Address Three$ RewriteRule ^(.*)$ - 
[R=403,L] </IfModule>
Share Improve this question asked Aug 17, 2017 at 13:59 HenryHenry 9831 gold badge8 silver badges31 bronze badges 2
  • Technically you can just send them to any link that doesn't exist and that will trigger the 404 page. – gdaniel Commented Aug 17, 2017 at 14:18
  • I assume the lack of line breaks in your code sample is just a typo in your question? Otherwise, this is wholly invalid. However, it looks like you are trying to serve a "not found" page for 401/403 status... unless you have additional (PHP) code that changes the status, then the client will still see a 403 status, not a 404. Why not just serve the 404 directly (ie. [R=404]) if that is the intention? – MrWhite Commented Aug 18, 2017 at 14:40
Add a comment  | 

1 Answer 1

Reset to default 0

I just made it a full URL Path so https://example.com/404.php and that works great....kinda obvious - and I wonder if that is 'not the WordPress way'

本文标签: htaccessUnable to find 39fullpath39 to my 404php file