Reputation: 3
How do I add some conditions to my htaccess
so that if I enter :
http://example.com/protectedpage.php
It redirect to:
http://example.com/no_access.php
Here is a list of files that I would like to protect from users:
protectedpage1, protectedpage2, protectedpage3,...
How do I achive it?
Upvotes: 0
Views: 137
Reputation: 785561
You can use regex alternation and have a simple RedirectMatch
rule like this:
RedirectMatch ^/(protectedpage1|protectedpage2|protectedpage3)\.php$ /no_access.php
Upvotes: 0
Reputation: 41219
Try this in your Root/.htaccess file
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/protectedpage1\.php [OR]
RewriteCond %{REQUEST_URI} ^/protectedpage2\.php [OR]
RewriteCond %{REQUEST_URI} ^/protectedpage3\.php
RewriteRule .* /no_access.php [L,R]
RewriteConditions check if the Requested URI string contains any of the spacified files then Server will redirect them to the no_access.php page.
Upvotes: 1