완전히 nginx에 익숙하지 않습니다.URL이 nginx.conf에 IIS의 web.config에 다시 작성됩니다.
어떻게이 URL을 nginx로 다시 작성 하시겠습니까?
<rewrite>
<rules>
<rule name="IndexFolders" stopProcessing="true">
<match url="(.*[^/]+)$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" />
</conditions>
<action type="Rewrite" url="/_index/{R:1}.html" />
</rule>
<rule name="OtherFile" stopProcessing="true">
<match url="\.\w+$" />
</rule>
<rule name="HtmlFile" stopProcessing="true">
<match url="^([^.]*[^/]+)$" />
<action type="Rewrite" url="{R:1}.html" />
</rule>
</rules>
</rewrite>
변환기를 시도했지만 작동하지 않습니다.
이 내 테스트 환경에서 작동location/{
if (-d $request_filename){
set $rule_0 1;
}
if ($rule_0 = "1"){
rewrite /(.*[^/]+)$ /_index/$1.html last;
}
location ~* /\.\w+$ {
break;
}
rewrite ^/([^.]*[^/]+)$ /$1.html last;
}
대신'rewrite /? ([^ /] +) $'를 사용해보세요. – hjpotter92
@ hjpotter92 당신은 무엇을 의미합니까? 작동하지 않고 500 개의 오류가 발생했습니다. –
'location ~ * /\.\w+$ {break; }'는'if ($ uri ~ * \. \ w + $) {break; }','break'는''location/{}'에 다른 재 작성 규칙을 실행하는 것을 멈추게 할 것임을 의미합니다. – xiaochen