# Moving .htaccess config to nginx

**URL:** <https://www.ruby-forum.com/t/moving-htaccess-config-to-nginx/219901>\
**Category:** NGINX\
**Created:** [May 21, 2012, 1:30pm UTC](https://www.ruby-forum.com/t/moving-htaccess-config-to-nginx/219901 "2012-05-21T13:30:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [May 21, 2012, 1:30pm UTC](https://www.ruby-forum.com/t/moving-htaccess-config-to-nginx/219901/1 "2012-05-21T13:30:13Z")

</div>

Hi,

I have to test nginx for my company which is currently using apache  
webservers with .htaccess files. I nearly managed to get all the config  
from apache to nginx, but I am having problems with the .htaccess files.  
I really have no idea how I should translate this configuration:

RewriteCond %{REQUEST\_FILENAME} !-f  
RewriteCond %{REQUEST\_FILENAME}###%{REQUEST\_URI}  
(._)/skinimage###._/skinimage/([^/]+)/([^/]+)$ [NC]  
RewriteCond %1/style/%2/images/%3 -f  
RewriteRule skinimage/([^/]+)/(.+)$ %{ENV:P4T\_DOC}/style/$1/images/$2  
[L,NC,QSA]

RewriteCond %{REQUEST\_FILENAME} !-f  
RewriteCond %{REQUEST\_FILENAME}###%{REQUEST\_URI}  
(._)/skinimage###._/skinimage/[^/]+/([^/]+)$ [OR,NC]  
RewriteCond %{REQUEST\_FILENAME} (.\*)/style/[^/]+/images/(.+)$ [NC]  
RewriteCond %1/style/default/images/%2 -f  
RewriteRule (skin)?images?/([^/]+/)?(.+)$  
%{ENV:P4T\_DOC}/style/default/images/$3 [L,NC,QSA]

RewriteCond %{REQUEST\_FILENAME} !-f  
RewriteCond %{REQUEST\_FILENAME}###%{REQUEST\_URI}  
(._)/skinimage###._/skinimage/[^/]+/([^/]+)$ [OR,NC]  
RewriteCond %{REQUEST\_FILENAME} (.\*)/style/[^/]+/images/(.+)$ [NC]  
RewriteCond %1/images/%2 -f  
RewriteRule (skin)?images?/([^/]+/)?(.+)$ %{ENV:P4T\_DOC}/images/$3  
[L,NC,QSA]

## Deny access to .svn directory via Web

RewriteRule ._.svn/._ - [F]

I am not even sure if I understand this config correct:  
If REQUEST\_FILENAME does not exist, check if it matches some regex, and  
then rewrite it with some parts of the none-existent path.

Could you please help me to apply this config to nginx?

Posted at Nginx Forum:

> **[Moving .htaccess config to nginx](https://forum.nginx.org/read.php?2,226685,226685#msg-226685)**
>
> Hi, I have to test nginx for my company which is currently using apache webservers with .htaccess files. I nearly managed to get all the config from apache to nginx, but I am having problems with the .htaccess files. I really have no idea how I...

---

<div class="post-metadata">

**Author:** ![kirodan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ecb155/32.png) [@kirodan](https://www.ruby-forum.com/u/kirodan)\
**Post date:** [May 21, 2012, 1:49pm UTC](https://www.ruby-forum.com/t/moving-htaccess-config-to-nginx/219901/2 "2012-05-21T13:49:11Z")

</div>

hi  
take a look over here, it will give you some idea

> **[htaccess-конвертер для nginx](https://winginx.com/ru/htaccess)**

On 21/5/2012 12:29, kirodan wrote:

> RewriteCond %1/style/%2/images/%3 -f
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

–  
-= MagenX =-  
Optimizing Your Magento and Nginx Performance  
Magento Bronze Solution Partner

> **[MagenX - High-Performance Magento Hosting](https://www.magenx.com/)**
>
> High-performance, fully managed Magento hosting with 24/7 expert support, 99.99% uptime SLA, and PCI compliance.

---

<div class="post-metadata">

**Author:** ![kirodan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ecb155/32.png) [@kirodan](https://www.ruby-forum.com/u/kirodan)\
**Post date:** [May 22, 2012, 12:13pm UTC](https://www.ruby-forum.com/t/moving-htaccess-config-to-nginx/219901/3 "2012-05-22T12:13:18Z")

</div>

Thank you, that helps alot.

## dedo Wrote:

> > webservers with .htaccess files. I nearly  
> > RewriteCond %1/style/%2/images/%3 -f  
> > RewriteCond %1/style/default/images/%2 -f  
> > RewriteCond %1/images/%2 -f  
> > If REQUEST\_FILENAME does not exist, check if it
> 
> [www.magenx.com](http://www.magenx.com)
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

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