我讀到.htaccess不能在像godaddy這樣的Windows服務器上工作。因此,要隱藏或刪除喜歡的擴展名爲.php和.html的網址,你可以用下面的代碼創建一個web.config文件實現這一點:隱藏/刪除Windows服務器的URL擴展
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="RewriteHTML">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions> <action type="Rewrite" url="{R:1}.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
我試圖讓web.config文件並將其保存在那裏的index.php是與代碼,但什麼也沒發生。我與測試它像這樣
<ul>
<li>
<a href="attackontitan-3">Attack on Titan Episode 3</a>
</li>
</ul> with a href of "attackontitan-3"
我想要的網址是http://mysite/watching/attack%20on%20titan/attackontitan-3不http://mysite/watching/attack%20on%20titan/attackontitan-3.php