开发者

Java web app: prevent a slash from being added to the path?

开发者 https://www.devze.com 2023-03-05 16:26 出处:网络
If I run a webapp under the uri /myapp then 开发者_Go百科as soon as the app is accessed via http://example.com/myapp, the URL changes to http://example.com/myapp/. Is there any way to prevent this?Whe

If I run a webapp under the uri /myapp then 开发者_Go百科as soon as the app is accessed via http://example.com/myapp, the URL changes to http://example.com/myapp/. Is there any way to prevent this?


When you have such a behaviour your web (or application) server returns a

301 Moved Permanently

when the URL without slash is requested.

You can see a similar example when getting 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

After this first HTTP get to http://www.google.es/services (without slash), the browser makes a second HTTP get to http://www.google.es/services/ (with slash). You can trace the HTTP requests with Network tab in Firebug, for example.

You can check your web/application server configuration, and maybe you can change this behaviour.

0

精彩评论

暂无评论...
验证码 换一张
取 消