开发者

Google App Engine optional slash redirect

开发者 https://www.devze.com 2023-03-21 16:07 出处:网络
I have a java app running on Google App Engine...I\'d like to make the trailing slash optional for directories... so navigating to www.domain.com/test and www.domain.com/test/ would yield the same thi

I have a java app running on Google App Engine... I'd like to make the trailing slash optional for directories... so navigating to www.domain.com/test and www.domain.com/test/ would yield the same thing.

How do I achieve that?

I know about the app.yaml configuration file but 开发者_如何学JAVAI am running a Java app not python..


See this post. Works for me, though looks like a hack. I think it worth posting issue to google, as thee servlet specification requires adding trailing slashes when attempting to find a proper welcome-file.


The easiest way to do this would be to create a filter that intercepts requests and appends the forward slash if necessary. Generally it's better to send a redirect rather than serving the same content, so you don't end up with two canonical URLs for everything, and all your contents indexed twice.

What constitutes a 'directory' depends on your application, of course, and there's no hard and fast rule for figuring that out.

0

精彩评论

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