# Apache .htaccess to Nginx rewrite

**URL:** <https://www.ruby-forum.com/t/apache-htaccess-to-nginx-rewrite/213375>\
**Category:** NGINX\
**Created:** [October 31, 2011, 4:21pm UTC](https://www.ruby-forum.com/t/apache-htaccess-to-nginx-rewrite/213375 "2011-10-31T16:21:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [October 31, 2011, 4:21pm UTC](https://www.ruby-forum.com/t/apache-htaccess-to-nginx-rewrite/213375/1 "2011-10-31T16:21:37Z")

</div>

Hi All,

I have a WP plugin and one of the futures is locking down the folder  
based on access level of the member. But they only support .htaccess /  
Apache.

I don’t want to scrap my nice NGINX installation for this problem. Can  
you any of you help me in converting the following .htaccess files to  
nginx config?

Thanks,

=====

each folder has a .htaccess file and they are as follows

/files/Silver/.htaccess

Options FollowSymLinks  
RewriteEngine on  
#RewriteCond %{REQUEST\_URI} ^Silver/\*  
RewriteRule ^(.\*)$ /index.php?wlmfolder=Silver&restoffolder=$1 [L]

/files/Gold/.htaccess

RewriteEngine on  
#RewriteCond %{REQUEST\_URI} ^Silver/\*  
RewriteRule ^(.\*)$ /index.php?wlmfolder=Gold&restoffolder=$1 [L]

/files/Platinum/.htaccess

RewriteEngine on  
#RewriteCond %{REQUEST\_URI} ^Silver/\*  
RewriteRule ^(.\*)$ /index.php?wlmfolder=Platinum&restoffolder=$1 [L]

Posted at Nginx Forum:

> **[Apache .htaccess to Nginx rewrite](https://forum.nginx.org/read.php?2,217553,217553#msg-217553)**
>
> Hi All, I have a WP plugin and one of the futures is locking down the folder based on access level of the member. But they only support .htaccess / Apache. I don't want to scrap my nice NGINX installation for this problem. Can you any of you help me...

---

<div class="post-metadata">

**Author:** ![morayi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a698b9/32.png) [@morayi](https://www.ruby-forum.com/u/morayi)\
**Post date:** [October 31, 2011, 4:36pm UTC](https://www.ruby-forum.com/t/apache-htaccess-to-nginx-rewrite/213375/2 "2011-10-31T16:36:28Z")

</div>

On 31 Out 2011 15h20 WET, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks,  
> RewriteRule ^(.\*)$ /index.php?wlmfolder=Silver&restoffolder=$1 [L]
> 
> /files/Platinum/.htaccess
> 
> RewriteEngine on  
> #RewriteCond %{REQUEST\_URI} ^Silver/\*  
> RewriteRule ^(.\*)$ /index.php?wlmfolder=Platinum&restoffolder=$1 [L]
> 
> Posted at Nginx Forum:  
> [http://forum.nginx.org/read.php?2,217553,217553#msg-217553](http://forum.nginx.org/read.php?2,217553,217553#msg-217553)

If you’re ok with an explicit redirect, try this for each folder:

location ^~ Silver/ {  
return 302 /index.php?wlmfolder=Silver&restoffolder=$uri;  
}

location ^~ Gold/ {  
return 302 /index.php?wlmfolder=Gold&restoffolder=$uri;  
}

location ^~ Platinum/ {  
return 302 /index.php?wlmfolder=Platinum&restoffolder=$uri;  
}

— appa
