Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

I'm trying to rewrite the following page:

http://test.domain.com/prova_pagina.php

to

http://test.domain.com/p/

I have the following in nginx.conf:

server {
  listen 82;

  root /dir;

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

  server_name test.domain.com;

  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) {
            fastcgi_pass 127.0.0.1:9000;
        }
    }
}

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

1 Answer 1

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 ^ http://test.domain.com/p/;
}
share|improve this answer

Your Answer

 
discard

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.