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