数据库中唯一链接的问题:www.doamin/或domain/

发布于 2024-09-02 07:56:52 字数 569 浏览 1 评论 0原文

在我的网站中,每个人都可以发送一些到其他好网站的链接。 我的数据库中的所有链接都必须是唯一的,但有些链接带有“www”。前缀,有些没有。 有些以“/”结尾,有些则不然。 例如:

|http://www.example.com

|http://example.com

|http://example.com

|http://example.com/

和其他问题可能与 https 或 http 有关。

我知道我应该在保存到数据库之前更改地址,但是我应该使用什么标准?

In my website everybody can send some links to other nice websites.
All links in my database must by unique, but some links are with 'www.' prefix, and some without.
Some ends for '/', some not.
For example:

|http://www.example.com

|http://example.com

|http://example.com

|http://example.com/

and other problems can be with https or http.

I know that I should change address before saving to database, but what standard I should use?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

慕烟庭风 2024-09-09 07:56:52

好吧,您不一定将 http://www.example.comhttp://example.com 视为同一个网站,因为它们可能提供不同的服务内容(尽管这会打破很多人的期望)

同样,http://https:// 地址不应被视为指向相同的内容。如果服务器设置正确,重复的 URL 将设置规范的重定向以指向另一个。如果服务器设置不正确,则很难判断重复是有意为之还是意外。

最好的方法是跟踪您提供的任何 URL,看看它是否重定向到另一个 URL。无论发生什么情况,请使用重定向后最终到达的 URL。

Well, you can't necessarily treat http://www.example.com and http://example.com as the same site, because they could serve up different content (although it would break a lot of peoples' expectations)

Similarly http:// and https:// addresses shouldn't be considered to point to the same content. If the server was set up correctly, duplicate URLs would have a canonical redirect set up to point one to the other. If the server isn't set up correctly it will be very difficult to tell whether the duplication is by design or accident.

The best approach would be to follow any URL you're given and see if it redirects to another. Whatever happens, use the URL you end up at after any redirects.

櫻之舞 2024-09-09 07:56:52

我会使用http://domain.com。无论您选择什么标准,只需在整个代码中坚持使用它即可。

I would use http://domain.com. Wether standard you choose, just stick with it throughout your code.

温柔女人霸气范 2024-09-09 07:56:52

我认为最短的一个,例如domain.com。但是,如果您有 ftp://domain.com,则需要向数据库添加其他协议列。

I think the shortest one, for example domain.com. But if you have ftp://domain.com, you need to add to your DB additional protocol columns.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文