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

I am really struggling to understand and achieve a very simple operation in nginx.

I'm trying to rewrite the following page:


I have the following in nginx.conf:

server {
  listen 82;

  root /dir;

  include /nginx/conf/mod_pagespeed.conf;
  include /nginx/conf/expiry_directives.conf;


  index theindex.php;

  location / {
      rewrite ^/d/ /prova_pagina.php last;

    location ~ \.php$ {
          include /nginx/conf/fastcgi_params;

        fastcgi_index theindex.php;

        if (-f $request_filename) {

It actually works but the problem is that all the external links such as css and js get /d/ appended after the domain.

Any help? Any simple tutorial that can make me understand how to properly achieve this?

Thanks for any help.

share|improve this question

Try it like this:

# serving normal pages
location / {
    try_files $uri $uri/ /index.php?$args;

# the page to be redirected
location /prova_pagina.php {
    rewrite ^;
share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.