结束我用斜线(/)或不网址吗?而且我怎么去了解它与codeigniter这样做 [英] End my urls with trailing slash (/) or not? And how do I go about it doing this with codeigniter

查看:140
本文介绍了结束我用斜线(/)或不网址吗?而且我怎么去了解它与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.

要解决这个问题,我改变了配置文件有$配置['url_suffix才能'] ='/'。这worked..MOSTLY很好..但我有一个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.

正因为如此,我选择不给力任何一方,而是建立我的网站反映用户感知的一种方式。但是那一种哲学的事情,你建立的用户,而不是为code网站,对不对? : - )

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天全站免登陆