# Apache .htaccess rewrite

**URL:** <https://www.ruby-forum.com/t/apache-htaccess-rewrite/186147>\
**Category:** NGINX\
**Created:** [April 1, 2010, 8:20am UTC](https://www.ruby-forum.com/t/apache-htaccess-rewrite/186147 "2010-04-01T08:20:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Payam\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/59ef9b/32.png) [@Payam\_C](https://www.ruby-forum.com/u/Payam_C)\
**Post date:** [April 1, 2010, 8:20am UTC](https://www.ruby-forum.com/t/apache-htaccess-rewrite/186147/1 "2010-04-01T08:20:57Z")

</div>

hey Guys,

I cant seem to figure out why I cant properly convert this from apache  
to nginx, any help would be appreciated… ive tried a dozen times but  
it just will not function as expected.

* * *

Options +FollowSymLinks  
RewriteEngine On  
RewriteBase /

# URL PATTERN for sitetown

# Main → Category

# [Custom Application Development Software for Business - Salesforce.com](http://www.site.com/category-name/)

RewriteRule ^([A-Za-z0-9-]+)/([0-9]+).html$  
results.php?category\_id=$2&category=$1 [L]

#New and Improved witht the .html support!  
RewriteRule ^([A-Za-z0-9-]+)/([0-9]+)/([0-9]+)/([A-Za-z0-9-]+).html$  
details.php?pid=$2&pkey=$3&category=$1&title=$4 [L]

RewriteRule ^(.\*).html$ $1.php

thanks in advance  
payam

---

<div class="post-metadata">

**Author:** ![Payam\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/59ef9b/32.png) [@Payam\_C](https://www.ruby-forum.com/u/Payam_C)\
**Post date:** [April 1, 2010, 9:33am UTC](https://www.ruby-forum.com/t/apache-htaccess-rewrite/186147/2 "2010-04-01T09:33:31Z")

</div>

On Wed, Mar 31, 2010 at 11:20:02PM -0700, Payam C. wrote:

> RewriteBase /  
> details.php?pid=$2&pkey=$3&category=$1&title=$4 [L]
> 
> RewriteRule ^(.\*).html$ $1.php

```
 location ~ \.html$ {
     rewrite ^/([A-Za-z0-9\-]+)/([0-9]+)\.html$
              /results.php?category_id=$2&category=$1
              last;

     rewrite 

```

^/([A-Za-z0-9-]+)/([0-9]+)/([0-9]+)/([A-Za-z0-9-]+).html$  
/details.php?pid=$2&pkey=$3&category=$1&title=$4  
last;

```
     rewrite ^(/.*)\.html$ $1.php last;
 }

 location ~ \.php$ {
     ...
 }

```

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**
