使用尾部斜杠(/)结束我的网址?和我怎么去它这样做与codeigniter [英] End my urls with trailing slash (/) or not? And how do I go about it doing this with codeigniter

查看:193
本文介绍了使用尾部斜杠(/)结束我的网址?和我怎么去它这样做与codeigniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我想弄清楚哪个是最合适的。从我已经阅读的文章,似乎最好结束url的尾部斜杠。

Hey guys, I am trying to figure out which is most appropriate. From the articles I have read, it seems best to end url's with a trailing slash.

而不是:
http:/ /www.site.com/article

它会显示为:
http://www.site.com/article/

首先我调整了htaccess,斜线。

First I adjusted my htaccess to force a trailing slash.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI}      ^.+[^/]$
RewriteRule ^(.+)$              $1/   

链接和我想如果我做锚('文章/','文章')它会工作,但似乎这个函数剥离尾部斜杠。

Then I started implementing this in my links and I thought if I did anchor('article/','article') it would work, but it seems that this function strips the trailing slash.

在这周围,我改变了配置文件有$ config ['url_suffix'] ='/'。其中工作..很好..除了我有一个文档区域在我的网站与pdf的等。因此,在那里创建的链接将会像 http://www.site.com/documents/ doc1.pdf / 。这当然不起作用。

To get around this I changed the config file to have $config['url_suffix'] = '/'. Which worked..MOSTLY fine.. except I have a document area on my site with pdf's and such. So the links created there would turn out like http://www.site.com/documents/doc1.pdf/ . This of course does not work.

你认为我的解决方案在这里是什么?我想我可以回到任何页面,我引用的文档或文件,并调整他们不使用锚功能,但我觉得应该有一个更容易的方法。

What do you think my solution is here? I guess I could go back to any page I referenced documents or files in and adjust them to not use the anchor function, but I feel like there should be an easier way.

谢谢!

推荐答案

我的网站使用两者。尾部的斜线表示用户特定的东西,我想。由于/通常表示一个文件夹,用户(特别是技术)采取这意味着有这个页面的子文件夹或子参数。不向用户显示斜杠可能表示没有子文件夹。这适用于像文件这样的文件,例如您的PDF文件。

My sites use both. The trailing slash indicates something specific to users, i think. Since the "/" usually indicates a folder, users (especially technical) take this to mean that there are sub-folders or sub-parameters to this page. Not showing a user that slash could indicate that there are no sub folders. This works for things like files, such as your pdf file.

因为这个原因,我选择不强制任何一方,反映了用户的看法。但是这是一个哲学的东西,你为用户建立一个网站,不是为代码,对吧? : - )

Because of this, I have chosen not to force either side, but to build my site in a way that reflects the users perceptions. But thats a philosophy thing, you build a site for users, not for the code, right? :-)

这篇关于使用尾部斜杠(/)结束我的网址?和我怎么去它这样做与codeigniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆