尝试缩短多个文件夹中的 90 多个网址

发布于 2024-11-08 19:29:43 字数 366 浏览 0 评论 0原文

我有超过 90 个网址,格式如下:

http://www.mysite.com /folder1/folder2/page.html

每个 URL 都将打印在纸上,供用户输入到地址栏中。目前的问题是它们太长,因此我需要使这些 URL 尽可能短。

但是,这样做的最佳方法是什么?

子文件夹是否是最好的选择,例如“keyword.mysite.com”?

我不想使用网址缩短服务,因为它们仍然需要与我的域名相关。由于网址的数量,转发到页面的其他域名也是不可能的。

理查德

I have over 90 urls set out in the following format:

http://www.mysite.com/folder1/folder2/page.html

Each of these URLs will be printed on paper for a user to input into their address bar. The problem at the moment is they are too long and therefore I need make these URLs as short as possible.

However, what would be the best method for doing so?

Would sub folders be the best thing here, such as "keyword.mysite.com"?

I don't want to use a url shortening service as they still need to be related to my domain name. Additional domain names forwarding on to the pages are also out of the question due to the quantity of urls.

Richard

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

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

发布评论

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

评论(2

年华零落成诗 2024-11-15 19:29:43

在不知道您正在使用什么技术(apache/php、asp.net、JSP 等)的情况下,我只能建议研究网址重写这里是 ASP.Net 重写器的代码项目示例。

Without knowing what technology you are working with (apache/php, asp.net, JSP, etc) all I can suggest is investigating Url Rewriting. Here is a codeproject example of a rewriter for ASP.Net.

一绘本一梦想 2024-11-15 19:29:43

我很快就会想到一些机制。一种是为您自己的域托管您自己的网址缩短服务:http://docs .example.com/xsdf 等等。为您自己的用户编写一个应该不会是太多工作,特别是因为您甚至可以编写一个快速脚本来提交所有 URL 以进行缩短和替换,而无需为人类制作一个漂亮的界面。

如果您想要更便宜的东西,但服务器管理员需要做更多的工作,您可以在 Web 服务器中使用标准的“重写”服务:

Apache mod_rewrite 指南

RewriteRule ^/xsdf$ folder1/folder2/page.html [R] 
RewriteRule ^/qwer$ folder2/folder3/page.html [R] 
RewriteRule ^/polz$ folder7/folder6/page.html [R] 

nginx HttpRewriteModule

rewrite  ^/xsdf$ folder1/folder2/page.html redirect;
rewrite  ^/qwer$ folder2/folder3/page.html redirect;
rewrite  ^/polz$ folder7/folder6/page.html redirect;

更新这些重写规则涉及编辑服务器配置文件,或删除新的配置文件。另一种机制将超出 Web 服务器本身的范围,因此长期维护可能会更容易或更困难,具体取决于您的团队将来更愿意使用哪种机制。

There's a handful of mechanisms that come to mind quickly. One is to host your own url-shortening service for your own domain: http://docs.example.com/xsdf and so forth. Writing one for your own users shouldn't be too much work, especially since you could even write a quick script to submit all the URLs for shortening and replace them all without ever making a pretty interface for a human.

If you want something even cheaper, but more work on the part of your server admins, you could use the standard 'rewriting' services in web servers:

Apache mod_rewrite guide

RewriteRule ^/xsdf$ folder1/folder2/page.html [R] 
RewriteRule ^/qwer$ folder2/folder3/page.html [R] 
RewriteRule ^/polz$ folder7/folder6/page.html [R] 

nginx HttpRewriteModule.

rewrite  ^/xsdf$ folder1/folder2/page.html redirect;
rewrite  ^/qwer$ folder2/folder3/page.html redirect;
rewrite  ^/polz$ folder7/folder6/page.html redirect;

Updating these rewrite rules involves editing the server config files, or dropping new ones in place. The other mechanism would be outside the range of the web server itself, so it might be easier or harder for long-term maintenance depending upon which your team would rather work with in the future.

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