# Please convert this .htaccess to NGINX rewrite

**URL:** <https://www.ruby-forum.com/t/please-convert-this-htaccess-to-nginx-rewrite/201104>\
**Category:** NGINX\
**Created:** [December 30, 2010, 9:07am UTC](https://www.ruby-forum.com/t/please-convert-this-htaccess-to-nginx-rewrite/201104 "2010-12-30T09:07:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [December 30, 2010, 9:07am UTC](https://www.ruby-forum.com/t/please-convert-this-htaccess-to-nginx-rewrite/201104/1 "2010-12-30T09:07:50Z")

</div>

could somebody convert this .htaccess to NGINX rewrite,??  
i need it stop my forum from automatic bot poster…

RewriteEngine on  
RewriteCond %{HTTP\_USER\_AGENT} ^._(6a1pre)._ [NC]  
RewriteRule ^(.\*)$ - [F,L]

if u could help me, u’re the best !

Posted at Nginx Forum:

> **[please convert this .htaccess to NGINX rewrite](https://forum.nginx.org/read.php?2,162173,162173#msg-162173)**
>
> could somebody convert this .htaccess to NGINX rewrite,,?? i need it stop my forum from automatic bot poster.. RewriteEngine on RewriteCond %{HTTP\_USER\_AGENT} ^.\*(6a1pre).\* \[NC\] RewriteRule ^(.\*)$ - \[F,L\] if u could help me, u're the best !

---

<div class="post-metadata">

**Author:** ![escavern](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/5f9b8f/32.png) [@escavern](https://www.ruby-forum.com/u/escavern)\
**Post date:** [December 30, 2010, 6:22pm UTC](https://www.ruby-forum.com/t/please-convert-this-htaccess-to-nginx-rewrite/201104/2 "2010-12-30T18:22:13Z")

</div>

On 30 Dez 2010 08h06 WET, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> could somebody convert this .htaccess to NGINX rewrite,??  
> i need it stop my forum from automatic bot poster..
> 
> RewriteEngine on  
> RewriteCond %{HTTP\_USER\_AGENT} ^._(6a1pre)._ [NC]  
> RewriteRule ^(.\*)$ - [F,L]

if ($http\_user\_agent ~\* “^._(6a1pre)._”) {  
return 403;  
}

— appa

---

<div class="post-metadata">

**Author:** ![escavern](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/5f9b8f/32.png) [@escavern](https://www.ruby-forum.com/u/escavern)\
**Post date:** [January 31, 2011, 4:56pm UTC](https://www.ruby-forum.com/t/please-convert-this-htaccess-to-nginx-rewrite/201104/3 "2011-01-31T16:56:53Z")

</div>

its not working, ☹ i think its not true antonio…

Posted at Nginx Forum:

> **[Re: please convert this .htaccess to NGINX rewrite](https://forum.nginx.org/read.php?2,162173,171085#msg-171085)**
>
> could somebody convert this .htaccess to NGINX rewrite,,?? i need it stop my forum from automatic bot poster.. RewriteEngine on RewriteCond %{HTTP\_USER\_AGENT} ^.\*(6a1pre).\* \[NC\] RewriteRule ^(.\*)$ - \[F,L\] if u could help me, u're the best !

---

<div class="post-metadata">

**Author:** ![escavern](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/5f9b8f/32.png) [@escavern](https://www.ruby-forum.com/u/escavern)\
**Post date:** [January 31, 2011, 5:20pm UTC](https://www.ruby-forum.com/t/please-convert-this-htaccess-to-nginx-rewrite/201104/4 "2011-01-31T17:20:45Z")

</div>

On 31 Jan 2011 15h55 WET, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> its not working, ☹ i think its not true antonio..

It should work. But the User Agent string _must_ contain ‘(6a1pre)’.

You can test it yourself with wget.

wget -U ‘This is a test of the evil UA (6a1pre) indeed’

you should get a 403 status code as the result.

— appa
