Nginx fiasco

Hey evryone,

I want to migrate from apache server to nginx server. So, i thought of setting up an nginx server + php-fpm + mysql combo on my system (Ubuntu Linux). Now, i have a very trivial query.

In apache, we can activate the mod_write system by the ‘RewriteEngine On’ statement in the .htaccess file. Does, anything have to be done in nginx too ??? any kind of activation that maybe required ???

I wrote some configuration, but it is not doing any url conversions at all.

I’ll put up the files, but please tell me about this first.

Thank you

mod_rewrite (and, in fact, .htaccess) is a feature specific to Apache. nginx does support some similar features, but it is NOT a drop-in replacement. See and for details.

Hey andrew,

Thanks for replying, i am so grateful u did.

But my problem is not that, i want to know what to do to get my rewrites working. I know nginx gives similar features. As below i have converted my rewrites but cannot understand how to get them working on my localhost.

Thanks again
Hey guys,

I am giving out the apache rewrite config and the config i wrote for nginx. Some other useful details :

  1. the apache rewrite rules are of .htacces file present under a directory admin under www. i.e the path is /var/www/admin for the .htaccess file.

  2. I placed the nginx conf rules straight under nginx.conf present /etc/nginx/nginx.conf

  3. When i installed nginx , i used the command " apt-get install nginx " on ubuntu, so i did not activate or disable any module installation.

  4. I have also installed the Perl Regular Expression Library explicitly, so i dont think that should be an issue.

  5. Another point, dont know how much useful. I am tryin to install a classifieds module i bought named ‘ikiclassifieds’ . Now its installation occurs through its own php file b[/b] inside the admin folder. I got to run it and it checks some settings, and if fine, installs.
    So, one of its setting’s telling me that my rewrite mode is off, and i cant understand why. The readme told me to type in my browser to start installation, so i wrote http://localhost/admin/install . Now, it doesnt show up anything clearly proving the rewrites arent working.
    Another thing that i noticed was. in the php code for installation, it was checking if a variable ‘page’ in the GET part of url had value ‘install’ and this comes through the rewrites (refer code below). When i tried tweaking it by passing the variable in GET myself a[/b]nd start installation, the url changed to install.htm and it showed 404 error, so it was to rewrite from htm to php which it didnt… phew…this point was a long one :stuck_out_tongue:

Apache .htaccess config =>

Options +FollowSymLinks

RewriteEngine on

RewriteBase /admin

RewriteCond %{REQUEST_URI} (/|.htm|.html|/[^.]*)$ [NC]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

#RewriteRule ^rss([0-9]{0,}),(.*).html$ rss.php?cat=$1 [L]

RewriteRule (.*) index.php?page=$1

RewriteRule templates/(.*).tpl$ index.php[F]

RewriteRule templates_c/(.*) index.php[F]

RewriteRule configs/(.*).conf$ index.php [F]

#RewriteRule ^p-(.*).html$ index.php?page=$1 [L]

Nginx config =>

listen 80;
server_name localhost;
root /var/www/admin;

location /
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?page=$1 last;

location ~* .(/|.htm|.html|/[^.]*)$
try_files $uri $uri/ index.php?page=$uri;

location = “/install” #added this coz i thgt maybe the first wasnt being accepted
try_files $uri $uri/ index.php?page=$uri;

location /templates/
rewrite ^(.*).tpl$ index.php permanent;

location /templates_c/
rewrite ^(.*) index.php permanent;

location /configs/
rewrite ^(.*).conf$ index.php permanent;