htaccess to nginx conversion?

tdubs nginx-forum at
Fri May 22 01:45:32 UTC 2015


I am working with a panel in which requires the pages to function properly
from the .htaccess file. However, I am no longer using Apache and have
decided to do a Centmin Mod LEMP web stack to improve performance and
whatnot. Anyways, I used this online converter and when I put the code it gave me into my
vhost.conf file, I got an error (see below). The error occurs even when I
place that code in my file, vhost.conf file, or nginx.conf
file. The URL types my panel uses are and it's throwing a 404 error
simply because it's not reading the .htaccess file since I'm using Nginx.

The error I'm receiving: 

[root at radio ~]# ngxrestart
nginx: [emerg] "location" directive is not allowed here in

Again, that happens even when I try the other files listed above. 

.htaccess code I need converted:

Options -Indexes

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico

  RewriteRule ^(.*)(\.)(.*)$ index.php?url=$1.$3 [L,QSA]
  RewriteRule ^ajax$ _res/ajax.php [QSA]
  #RewriteRule ^(.*)$ index.php?t=$1 [L,QSA]

I am using a Linux VPS running CentOS 6.5 if that information is needed.

Thank you!

Posted at Nginx Forum:,259054,259054#msg-259054

More information about the nginx mailing list