Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Im trying to set up URL Rewrites for my MVC Framework but as this is the first time i have used Nginx I am having a little trouble.

I have 2 access points for my application:

  • /index.php
  • /admin/index.php

I need to route the URL for those folders / access points to the according index file, for example:

  • /admin/auth/login/ >>> /admin/index.php?/auth/login/
  • /contact/ >>> /index.php?/contact/

This is what I have so far:

server {
listen 7000;
listen localhost:7000;

    location / {
        root   /srv/www/htdocs/ASDDL/;
        index index.php;

    location /admin/ {
        root   /srv/www/htdocs/ASDDL/admin/;
        index index.php;

    location ~ \.php$ {
        fastcgi_index    index.php;
        fastcgi_param  SCRIPT_FILENAME /srv/www/htdocs/ASDDL/$fastcgi_script_name;
        include fastcgi_params;

Now as you can see that i think the problem lies with the following line:

fastcgi_param  SCRIPT_FILENAME /srv/www/htdocs/ASDDL/$fastcgi_script_name;

Where it's not routing to the admin folder because it tries to route to the root index.php file, can anyone shed some light on the correct way to do this?

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.