Home > Software engineering >  How to set 403 Forbidden on single page via .htaccess
How to set 403 Forbidden on single page via .htaccess

Time:11-12

How to use 403 forbidden for 1 single page. I have been using the following code below on directory level like on my WordPress site /wp-content/, /wp-includes/ & it works. But How to achieve for a single file like /example-service.html so that when anyone visit the page /example-service.html it returns 403 forbidden (in .htaccess)

<files>
order allow, deny
deny from all
</files>

CodePudding user response:

You can use the following RewriteRule to redirect /example-service.html to 403 error.

RewriteEngine On

RewriteRule ^example-service.html$ - [R=403]

CodePudding user response:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /Index.php [L]
  • Related