WorkHolic

아파치 - 특정 쿼리 단어로 URL 차단

gromet 2024. 1. 12. 19:41
728x90
반응형

아파치 - 특정 쿼리 단어로 URL 차단

 

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine On
RewriteCond %{QUERY_STRING} (test|user|password) [NC]
RewriteRule .* - [F,L]
</VirtualHost>

 

아래와 같이 시도하면 그 아래와 같이 차단한다.


curl -I  http://www.gameking.tips?test=1
curl -I  http://www.gameking.tips?var1=user
curl -I  http://www.gameking.tips?mypassword=abcd

HTTP/1.1 403 Forbidden
Date: Sun, 18 Apr 2021 18:18:53 GMT
Server: Apache/2.4.41 (Ubuntu)
Content-Type: text/html; charset=iso-8859-1

 

HTACCESS를 사용하여 특정 쿼리 문자열로 URL 차단

 

vi /var/www/html/.htaccess

RewriteEngine On
RewriteCond %{QUERY_STRING} (test|user|password) [NC]
RewriteRule .* - [F,L]

 

참고 - https://techexpert.tips/ko/apache-ko/%ec%95%84%ed%8c%8c%ec%b9%98-%ed%8a%b9%ec%a0%95-%ec%bf%bc%eb%a6%ac-%eb%8b%a8%ec%96%b4%eb%a1%9c-url-%ec%b0%a8%eb%8b%a8/

728x90
SMALL