
인수가 있는 URL에서 .html을 어떻게 제거할 수 있나요?
예: http://www.domain.com/somepage.html?argument=whole&bunch=a-lot
에게:
http://www.domain.com/somepage?argument=whole&bunch=a-lot
나는 시도했다
location / {
index index.html index.php;
rewrite ^\.html(.*)$ $1 last;
try_files $uri $uri/ @handler;
expires 30d; ## Assume all files are cachable
}
그리고 다른 많은 제안들이 있지만 제대로 작동하지 않는 것 같습니다....
Tnx
답변1
다음과 같이 구성을 수정하십시오.
# rewrite html extensions
rewrite ^(/.+)\.html$ $scheme://$host$1 permanent;
location / {
index index.html index.php;
# this way nginx first tries to serve the file as an .html although it doesn't have the extension
try_files $uri.html $uri $uri/ @handler;
}
물론 캐시 설정 등을 추가할 수 있지만 이는 .html 부분을 제거하는 데 충분합니다.