# Convert Apache .htaccess rewrite to nginx

**URL:** <https://www.ruby-forum.com/t/convert-apache-htaccess-rewrite-to-nginx/242427>\
**Category:** NGINX\
**Created:** [June 23, 2015, 5:21pm UTC](https://www.ruby-forum.com/t/convert-apache-htaccess-rewrite-to-nginx/242427 "2015-06-23T17:21:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [June 23, 2015, 5:21pm UTC](https://www.ruby-forum.com/t/convert-apache-htaccess-rewrite-to-nginx/242427/1 "2015-06-23T17:21:51Z")

</div>

Hello,  
I am new to nginx and I am having trouble converting htaccess rewrite to  
nginx rewrite. Please help me convert the following mod\_rewrites with a  
brief explanation. And should I put the nginx rewrite back into the  
.htaccess file or is there a designated config file to put the nginx  
location blocks?

 Options -MultiViews 

```
RewriteEngine On

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

```

Posted at Nginx Forum:

> **[Convert Apache .htaccess rewrite to nginx](https://forum.nginx.org/read.php?2,259810,259810#msg-259810)**
>
> Hello, I am new to nginx and I am having trouble converting htaccess rewrite to nginx rewrite. Please help me convert the following mod\_rewrites with a brief explanation. And should I put the nginx rewrite back into the .htaccess file or is there a...

---

<div class="post-metadata">

**Author:** ![nngin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e8c25b/32.png) [@nngin](https://www.ruby-forum.com/u/nngin)\
**Post date:** [June 24, 2015, 9:31pm UTC](https://www.ruby-forum.com/t/convert-apache-htaccess-rewrite-to-nginx/242427/2 "2015-06-24T21:31:31Z")

</div>

searching the site, i found that this same question goes unanswered.  
Please  
point me in the right direction of where i would be able to get help.

Posted at Nginx Forum:

> **[Re: Convert Apache .htaccess rewrite to nginx](https://forum.nginx.org/read.php?2,259810,259876#msg-259876)**
>
> Hello, I am new to nginx and I am having trouble converting htaccess rewrite to nginx rewrite. Please help me convert the following mod\_rewrites with a brief explanation. And should I put the nginx rewrite back into the .htaccess file or is there a...

---

<div class="post-metadata">

**Author:** ![nngin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e8c25b/32.png) [@nngin](https://www.ruby-forum.com/u/nngin)\
**Post date:** [June 26, 2015, 1:11am UTC](https://www.ruby-forum.com/t/convert-apache-htaccess-rewrite-to-nginx/242427/3 "2015-06-26T01:11:48Z")

</div>

On Wed, Jun 24, 2015, 15:31 nngin [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

searching the site, i found that this same question goes unanswered.  
Please  
point me in the right direction of where i would be able to get help.

Posted at Nginx Forum:

> **[Re: Convert Apache .htaccess rewrite to nginx](https://forum.nginx.org/read.php?2,259810,259876#msg-259876)**
>
> Hello, I am new to nginx and I am having trouble converting htaccess rewrite to nginx rewrite. Please help me convert the following mod\_rewrites with a brief explanation. And should I put the nginx rewrite back into the .htaccess file or is there a...

* * *

nginx mailing list  
removed\_email\_address@domain.invalid  
[http://mailman.nginx.org/mailman/listinfo/nginx](http://mailman.nginx.org/mailman/listinfo/nginx)

Not quite familiar with apache rewrite rules, but I think you just need:

rewrite ^(.\*)/$ $1 permanent;  
try\_files $uri /index.php;

Not tested, apologies if I’m wrong.
