For example, http://demo.com/hello, I want to restrict access to only the IP address 211.125.10.5. Access from other IP addresses will return 403. How should I write .htaccess
PS1:
/hello is not a directory, so you cannot use .htaccess directory-based IP restrictions
PS2:
The website is based on WordPress and now has the following rewrite rules.
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
PS3:
I just tried a solution, but it was always 500
This solution was rejected, the Location directive cannot be written in the .htaccess file...
<Location /hello/ > Order Deny,Allow Deny from all Allow from 211.125.10.5 </Location>
Apache will search whether there is
.htaccess
in each directory, so you only need to set it in the subdirectory. The restriction method is the same as the main directory restriction.Or don't use
Location
,使用Directory
块来限制,或者使用files
to limit the executable file.