# Htaccess

**URL:** <https://www.ruby-forum.com/t/htaccess/222360>\
**Category:** NGINX\
**Created:** [August 27, 2012, 2:00pm UTC](https://www.ruby-forum.com/t/htaccess/222360 "2012-08-27T14:00:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [August 27, 2012, 2:00pm UTC](https://www.ruby-forum.com/t/htaccess/222360/1 "2012-08-27T14:00:52Z")

</div>

Hi,

I am pasting part of my .htacess file used in Apache; please help me to  
convert this to nginx configuraiton settings:

…

############################################

## enable rewrites

```
Options +FollowSymLinks
RewriteEngine on

```

############################################

## you can put here your magento root folder

## path relative to web root

```
#RewriteBase /magento/

```

############################################

## uncomment next line to enable light API calls processing

# RewriteRule ^api/([a-z][0-9a-z\_]+)/?$ api.php?type=$1 [QSA,L]

############################################

## rewrite API2 calls to api.php (by now it is REST only)

```
RewriteRule ^api/rest api.php?type=rest [QSA,L]

```

############################################

## workaround for HTTP authorization

## in CGI environment

```
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

```

############################################

## TRACE and TRACK HTTP methods disabled to prevent XSS attacks

```
RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
RewriteRule .* - [L,R=405]

```

############################################

## redirect for mobile user agents

```
#RewriteCond %{REQUEST_URI} !^/mobiledirectoryhere/.*$
#RewriteCond %{HTTP_USER_AGENT}

```

“android|blackberry|ipad|iphone|ipod|iemobile|opera  
mobile|palmos|webos|googlebot-mobile” [NC]  
#RewriteRule ^(.\*)$ /mobiledirectoryhere/ [L,R=302]

############################################

## always send 404 on missing files in these folders

```
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

```

############################################

## never rewrite for existing files, directories and links

```
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

```

############################################

## rewrite everything else to index.php

```
RewriteRule .* index.php [L]

```

....................................................

Thank You.

Posted at Nginx Forum:

> **[htaccess](https://forum.nginx.org/read.php?2,230106,230106#msg-230106)**
>
> Hi, I am pasting part of my .htacess file used in Apache; please help me to convert this to nginx configuraiton settings: ....................................... \<IfModule mod\_rewrite.c\> ############################################ ##

---

<div class="post-metadata">

**Author:** ![iqbalmp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7cd45c/32.png) [@iqbalmp](https://www.ruby-forum.com/u/iqbalmp)\
**Post date:** [August 27, 2012, 2:04pm UTC](https://www.ruby-forum.com/t/htaccess/222360/2 "2012-08-27T14:04:32Z")

</div>

How about taking a look at [Winginx - Local web server for PHP5, MySQL, MongoDB, Node.js developers](http://winginx.com/htaccess). ?

–

_Yours sincerely,_  
_Christopher M._

Ambassador/Contributor of Fedora Project and many others.

> **[Magic Transit LaB](http://cicku.me)**
>
> DDoS Protection for Networks - Cloudflare

---

<div class="post-metadata">

**Author:** ![iqbalmp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7cd45c/32.png) [@iqbalmp](https://www.ruby-forum.com/u/iqbalmp)\
**Post date:** [August 27, 2012, 2:05pm UTC](https://www.ruby-forum.com/t/htaccess/222360/3 "2012-08-27T14:05:51Z")

</div>

> **[htaccess to nginx converter](https://winginx.com/en/htaccess)**

resulted :

=====================

# nginx configuration

index index.php;

charset off;

location ~ /(media|skin|js)/ {  
}

location /api {  
rewrite ^/api/rest /api.php?type=rest break;  
}

location / {  
if (!-e $request\_filename){  
rewrite ^(.\*)$ /index.php break;  
}  
}

location /RELEASE\_NOTES.txt {  
deny all;  
}

# ================ But I already have a ‘location’ settings in my nginx.conf:

# location / { root /var/www/html; index index.php index.html index.htm; fastcgi\_param REDIRECT\_STATUS 200; }

how can i merge both of this?

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,230106,230109#msg-230109](http://forum.nginx.org/read.php?2,230106,230109#msg-230109)

---

<div class="post-metadata">

**Author:** ![iqbalmp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7cd45c/32.png) [@iqbalmp](https://www.ruby-forum.com/u/iqbalmp)\
**Post date:** [August 27, 2012, 2:05pm UTC](https://www.ruby-forum.com/t/htaccess/222360/4 "2012-08-27T14:05:53Z")

</div>

> **[htaccess to nginx converter](https://winginx.com/en/htaccess)**

resulted :

=====================

# nginx configuration

index index.php;

charset off;

location ~ /(media|skin|js)/ {  
}

location /api {  
rewrite ^/api/rest /api.php?type=rest break;  
}

location / {  
if (!-e $request\_filename){  
rewrite ^(.\*)$ /index.php break;  
}  
}

location /RELEASE\_NOTES.txt {  
deny all;  
}

# ================ But I already have a ‘location’ settings in my nginx.conf:

# location / { root /var/www/html; index index.php index.html index.htm; fastcgi\_param REDIRECT\_STATUS 200; }

how can i merge both of this?

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,230106,230108#msg-230108](http://forum.nginx.org/read.php?2,230106,230108#msg-230108)
