# Mod\_rewrite with Nginx?

**URL:** <https://www.ruby-forum.com/t/mod-rewrite-with-nginx/244359>\
**Category:** NGINX\
**Created:** [March 26, 2016, 5:56pm UTC](https://www.ruby-forum.com/t/mod-rewrite-with-nginx/244359 "2016-03-26T17:56:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [March 26, 2016, 5:56pm UTC](https://www.ruby-forum.com/t/mod-rewrite-with-nginx/244359/1 "2016-03-26T17:56:03Z")

</div>

Hello is the first time that NGINX uses, and I’m turning my .htaccess to  
use  
it. Unfortunately the access is really long, and it is my first time I  
do  
this.  
I converted the .htaccess with nginx online tool, but unfortunately,  
load  
the conf changed, I restart the nginx service.

When I click a link on the page, it automatically downloads Him the .php  
files.

Here’s my .htaccess file: [http://pastebin.com/QiNGGbbn](http://pastebin.com/QiNGGbbn)

Below is my .conf instead of Nginx: [http://pastebin.com/7DZKChGm](http://pastebin.com/7DZKChGm)

Posted at Nginx Forum:

> **[mod\_rewrite with Nginx?](https://forum.nginx.org/read.php?2,265668,265668#msg-265668)**
>
> Hello is the first time that NGINX uses, and I'm turning my .htaccess to use it. Unfortunately the access is really long, and it is my first time I do this. I converted the .htaccess with nginx online tool, but unfortunately, load the conf changed, I...

---

<div class="post-metadata">

**Author:** ![Askancy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecccb3/32.png) [@Askancy](https://www.ruby-forum.com/u/Askancy)\
**Post date:** [March 26, 2016, 11:14pm UTC](https://www.ruby-forum.com/t/mod-rewrite-with-nginx/244359/2 "2016-03-26T23:14:24Z")

</div>

This online tool convert your .htaccess to nice nginx stuff 🙂 PS:  
IT’s  
not failproff but would help you a lot.

[http://winginx.com/en/htaccess](http://winginx.com/en/htaccess)

Posted at Nginx Forum:

> **[Re: mod\_rewrite with Nginx?](https://forum.nginx.org/read.php?2,265668,265670#msg-265670)**
>
> Hello is the first time that NGINX uses, and I'm turning my .htaccess to use it. Unfortunately the access is really long, and it is my first time I do this. I converted the .htaccess with nginx online tool, but unfortunately, load the conf changed, I...

---

<div class="post-metadata">

**Author:** ![Askancy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecccb3/32.png) [@Askancy](https://www.ruby-forum.com/u/Askancy)\
**Post date:** [March 26, 2016, 11:27pm UTC](https://www.ruby-forum.com/t/mod-rewrite-with-nginx/244359/3 "2016-03-26T23:27:16Z")

</div>

Hi, thanks for the reply, I used it … but it still does not work …

This is my new conf: [http://pastebin.com/93b58G68](http://pastebin.com/93b58G68) but it does not  
work…

Posted at Nginx Forum:

> **[Re: mod\_rewrite with Nginx?](https://forum.nginx.org/read.php?2,265668,265671#msg-265671)**
>
> Hello is the first time that NGINX uses, and I'm turning my .htaccess to use it. Unfortunately the access is really long, and it is my first time I do this. I converted the .htaccess with nginx online tool, but unfortunately, load the conf changed, I...

---

<div class="post-metadata">

**Author:** ![Askancy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecccb3/32.png) [@Askancy](https://www.ruby-forum.com/u/Askancy)\
**Post date:** [March 27, 2016, 10:12pm UTC](https://www.ruby-forum.com/t/mod-rewrite-with-nginx/244359/4 "2016-03-27T22:12:16Z")

</div>

Copy-pasting configuration of using pre-cooked one is always a bad idea  
since you do not understand what you are dealing with.

The same applies to automatic conversion tools since the paradigm behind  
the Apache Web server is totally different from the one from nginx:  
there  
is no one-to-one relationship (bijection) between the way to redact  
Apache  
configuration directives and nginx’ ones, so the very idea of such a  
tool  
is flawed. Too bad people keep trying to provide their attempt at it  
without thinking about that first.

You deleted the first pastebins you provided. People reading the thread  
entirely thus cannot get a hang on your initial question. If you do the  
same about the last one, the whole thread will transform into junk for  
future reference.  
Now, about the configuration you provided in the last pastebin:

1. For the list of console names, a single rewrite at server level  
would  
have proven enough. You could have transformed it into a regex  
location +  
rewrite to take advantage of the precedence of location blocks  
depending on  
their type/modifiers
2. You could have grouped all the location blocks doing a similar  
jobs  
together
3. You do not provide a location dealing with the index.php file, so  
the  
default behavior would be for nginx to serve that file
4. You do not provide the whole configuration as there is no http  
block  
(which contains the server ones) nor do you provide what is in the  
included  
files at the end of it (particularly the one php.conf one whoch could  
prove  
useful)

​Please take some time to read nginx docs [http://nginx.org/en/docs/](http://nginx.org/en/docs/) to  
get a hang on the basics.​ There even is a ‘Beginner’s Guide’ to help  
you  
through.  
Generic tip: it is usually a good idea to prepare a minimal  
configuration  
depicting your problem rather than sending a huge, incomplete,  
configuration fil which is, in the end, useless. You are not encouraging  
people to help. Do your homework to show people you tried solving your  
own  
problem and saving as much of their time as possible.

## ​My 2 cents,

_B. R._

On Sat, Mar 26, 2016 at 11:26 PM, Askancy [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
