0

如果我在 uri 下运行 webapp,/myapp那么只要通过 访问该应用程序http://example.com/myapp,URL 就会更改为http://example.com/myapp/. 有什么办法可以防止这种情况发生吗?

4

1 回答 1

2

当您有这样的行为时,您的 Web(或应用程序)服务器会返回一个

301 Moved Permanently

当请求不带斜线的 URL 时。

获取http://www.google.es/services时可以看到类似的示例

HTTP/1.1 301 Moved Permanently
Location: http://www.google.es/services/
Content-Type: text/html; charset=UTF-8
X-Content-Type-Options: nosniff
Date: Wed, 11 May 2011 15:24:06 GMT
Expires: Fri, 10 Jun 2011 15:24:06 GMT
Cache-Control: public, max-age=2592000
Server: sffe
Content-Length: 227
X-XSS-Protection: 1; mode=block

在第一次 HTTP 访问http://www.google.es/services (不带斜线)之后,浏览器会进行第二次 HTTP 访问http://www.google.es/services/(带斜线)。例如,您可以使用 Firebug 中的 Network 选项卡跟踪 HTTP 请求。

您可以检查您的 Web/应用程序服务器配置,也许您可​​以更改此行为。

于 2011-05-11T15:31:33.020 回答