doureng1083 2011-01-14 08:09
浏览 24
已采纳

/ thanks和/ thanks /之间的区别(http状态301)

I have a website and one of the sub folders is /thanks.

So the complete URI for the (one) page would be

/thanks/index.php

Now when i type

/thanks/ i get a 200 return status and it picks up the (default) page index.php

however, when I type /thanks I get a 301 redirect to /thanks/

<address>Apache/2.2.8 (Linux/SUSE) Server at www.mydomain.net Port 80</address>

While the behaviour is correct, I would like the /thanks to also serve the /thanks/ folder directly, without the 301.

Is that possible?

By the way, it looks like apache is generating the 301 'automatically', I wonder: what page or source is actually called when you call /thanks in stead of /thanks/

  • 写回答

3条回答 默认 最新

  • duanhua5523 2011-01-14 08:21
    关注

    This behavior is by design, cause url "/thanks" should actually refer to the file. Only for your convenience a web-server checks whether such file exists, if not then whether such directory exists, and if it is, it redirects the request to the correct destination "/thanks/".

    It is actually a best practice to enforce/use trailing slash wherever possible, it is a canonical form, it reduces load on the web server (parsing one HTTP request instead of two - original and redirect), and improves your search engine optimization.

    As for how to fix this, the question whether it needs fixing is still standing. If you fix this through say URL rewrite, your users will keep using the incorrect/bad-for-your-SEO URL. If you fix all the links at your site to use correct form and employ the default fix scheme - redirect - then the redirect would once redirect your users to the correct URL, and users will be using the correct version by default foreverafter (at least, in this session).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏