1

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.

0

1 Answer 1

0

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/;
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .