Examples of using the .htaccess file for working with links on an Apache web server. These lines should be added to the .htaccess file located in the root directory of the site.
Note the presence of the following line at the beginning:
RewriteEngine On
1. Blocking a link by match
RewriteCond %{THE_REQUEST} /path/link [NC]
RewriteRule ^ - [F]
2. Blocking a link by match (example 2)
RewriteCond %{THE_REQUEST} /link.html [NC]
RewriteRule ^ - [F]
3. Blocking a link for everyone except allowed IP addresses
RewriteCond %{REQUEST_URI} ^/admin.php
RewriteCond %{REMOTE_ADDR} !=79.xxx.71.xx
RewriteCond %{REMOTE_ADDR} !=10.0.0.3
RewriteRule ^(.*)$ - [R=403,L]
4. Blocking a dynamic link with a parameter, except for an allowed IP
RewriteCond %{QUERY_STRING} ^do=pm$ [NC]
RewriteCond %{REMOTE_ADDR} =11.22.33.44
RewriteRule ^index\.php$ - [F]
5. Redirecting a link to another section of the site
Redirect 301 /login http://domain.tld
No Comments Yet