nginx 単一の PHP ページを書き換える

nginx 単一の PHP ページを書き換える

私は nginx での非常に単純な操作を理解し、実現するのに本当に苦労しています。

次のページを書き直そうとしています:

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

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

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

実際には動作しますが、問題は、css や js などのすべての外部リンクのドメインの後に /d/ が追加されることです。

何か助けはありますか?これを適切に達成する方法を理解できる簡単なチュートリアルはありますか?

ご協力いただきありがとうございます。

答え1

次のように試してください:

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

関連情報