Question
[Help Me] Convert htaccess to nginx
I want to convert this to nginx rules
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?domain.com [NC]
RewriteRule .(jpg|jpeg|png|gif)$ - [NC,F,L]
I’ve tried to put this on the web but I can not even open.
if ($http_referer !~ "^$"){
set $rule_0 1$rule_0;
}
if ($http_referer !~* "^http(s)?://(www.)?domain.com"){
set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
return 403;
break;
}
I would like .htaccess above script can work smoothly in nginx.
if there is something wrong please correct. and show me the correct script ..
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×