1

https://mywebsite.com/contextroot/basic.html

The above url is working fine because my project has basic.html under the "deployedResources/webapp"

But when I enter the url as https://mywebsite.com/contextroot/basic.html/ I am getting 403 forbidden.

How do I remove the "/" from the url automatically and get the file basic.html?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
vemak
  • 33
  • 8
  • thanks for removing the unwanted words and framing it correctly – vemak Jan 08 '16 at 19:57
  • You should rewrite url somehow, here is example: http://stackoverflow.com/questions/8711392/spring-mvc-urls-with-trailing-slash-redirection or maybe setting `com.ibm.ws.webcontainer.RedirectWithPathInfo` property will be enough (according to: http://www-01.ibm.com/support/knowledgecenter/api/content/nl/pl/SS7JFU_7.0.0/com.ibm.websphere.express.doc/info/exp/ae/rweb_custom_props.html#com.ibm.ws.webcontainer.RedirectWithPathInfo) – glw Jan 08 '16 at 23:44
  • it is good now, thankyou so much :) – vemak Jan 13 '16 at 14:32

1 Answers1

2

The 403 status code is a result of the Application Server trying to serve this URL as a static resource and finding that it ends on a slash and identifying this as a request to a directory (due to the trailing slash). Directory browsing is disabled by default, thus the 403 forbidden status.

A possible simple solution to this problem is to add a filter to your web application to remove the trailing slash from the URL. See the accepted answer and question update here for an example:

How to use a servlet filter in Java to change an incoming servlet request url?

Another option is to use URL rewrite rules in your Web Server (if you are using one).

Community
  • 1
  • 1
ZRoman
  • 180
  • 6