apache - .htaccess How to set IP whitelist permissions for a specific request?
PHP中文网
PHP中文网 2017-05-16 17:04:32
0
1
928

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  RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]  # 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...

 Order Deny,Allow Deny from all Allow from 211.125.10.5 
PHP中文网
PHP中文网

认证0级讲师

reply all (1)
仅有的幸福

Apache will search whether there is.htaccessin 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 useLocation,使用Directory块来限制,或者使用filesto limit the executable file.

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!