Nginx fiasco

aditya a. lists at
Fri Apr 22 12:39:37 MSD 2011

Hey guys,

I am giving out the apache rewrite config and the config i wrote for
nginx. I am not able to get the rewrite rules to work. Please help me
get rid of the problem.

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
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 (install2.php) inside the
admin folder. I got to run it and it checks some settings, and if fine,
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 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
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;

Posted via

More information about the nginx mailing list