# Optimize rewrite

**URL:** <https://www.ruby-forum.com/t/optimize-rewrite/226888>\
**Category:** NGINX\
**Created:** [February 24, 2013, 10:18pm UTC](https://www.ruby-forum.com/t/optimize-rewrite/226888 "2013-02-24T22:18:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/59ef9b/32.png) [@Anto](https://www.ruby-forum.com/u/Anto)\
**Post date:** [February 24, 2013, 10:18pm UTC](https://www.ruby-forum.com/t/optimize-rewrite/226888/1 "2013-02-24T22:18:44Z")

</div>

hello

I have a script that works with apache but I want to migrate to nginx, I  
have this rule, but maybe you can do differently optimized.

## HTACCESS
 RewriteEngine On

RewriteCond %{REQUEST\_FILENAME} !-d  
RewriteCond %{REQUEST\_FILENAME} !-s  
RewriteRule ^(.\*)$ index.php?url=$1 [QSA,NC,L]

RewriteCond %{REQUEST\_FILENAME} -d  
RewriteRule ^(.\*)$ index.php [QSA,NC,L]

RewriteCond %{REQUEST\_FILENAME} -s  
RewriteRule ^(.\*)$ index.php [QSA,NC,L]

## NGINX

location / {  
rewrite ^/(._)/(._)$ /$1/index.php?url=$2;  
}

Thanks !!

Regards
