# How to convert Apache rewrite rule to nginx

**URL:** <https://www.ruby-forum.com/t/how-to-convert-apache-rewrite-rule-to-nginx/198950>\
**Category:** NGINX\
**Created:** [November 11, 2010, 5:12am UTC](https://www.ruby-forum.com/t/how-to-convert-apache-rewrite-rule-to-nginx/198950 "2010-11-11T05:12:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![okkezSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Post date:** [November 11, 2010, 5:12am UTC](https://www.ruby-forum.com/t/how-to-convert-apache-rewrite-rule-to-nginx/198950/1 "2010-11-11T05:12:55Z")

</div>

Hi

I have a RewriteRule in Apache :

RewriteCond %{QUERY\_STRING} came\_from=http(.\*)

RewriteRule ^/(.\*)login\_form$  
https://%{SERVER\_NAME}/$1login\_form?came\_from=https%1 [NE,L]

Can somebody let me know the equivalent of the above apache rewrite  
rule in nginx

---

<div class="post-metadata">

**Author:** ![threaded123](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f475e1/32.png) [@threaded123](https://www.ruby-forum.com/u/threaded123)\
**Post date:** [November 12, 2010, 1:14pm UTC](https://www.ruby-forum.com/t/how-to-convert-apache-rewrite-rule-to-nginx/198950/2 "2010-11-12T13:14:14Z")

</div>

Have you tried using something that would capture the header  
information? E.g., $http\_referer and such? The rules themselves aren’t  
extremely tough, so you’ve probably solved this by now (:

Posted at Nginx Forum:

> **[Re: How to convert Apache rewrite rule to nginx](https://forum.nginx.org/read.php?2,149695,150098#msg-150098)**
>
> Hi I have a RewriteRule in Apache : RewriteCond %{QUERY\_STRING} came\_from=http(.\*) RewriteRule ^/(.\*)login\_form$ https://%{SERVER\_NAME}/$1login\_form?came\_from=https%1 \[NE,L\] Can somebody let me know the equivalent of the above apache
