我可以使用 WebBroker 和 Delphi 创建干净的 URL 吗?
我可以为网上经纪服务网页/应用程序创建一个干净的 URL 吗?
典型的网上经纪商 URL 通常如下所示:
hxxp://www.mywebsite.com/myapp.dll?name=fred
或
hxxp://www.mywebsite.com/myapp.dll/names/fred
我更喜欢的是:
hxxp ://www.mywebsite.com/names/fred
知道如何使用 Delphi/WebBroker 实现此目的吗? (ISAPI/阿帕奇)
Can I create a clean URL for WebBroker webpages/applications ?
A typical WebBroker URL normally looks like:
hxxp://www.mywebsite.com/myapp.dll?name=fred
or
hxxp://www.mywebsite.com/myapp.dll/names/fred
What I would prefer is:
hxxp://www.mywebsite.com/names/fred
Any idea how I can achieve this with Delphi/WebBroker ? (ISAPI/Apache)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
执行此操作的典型方法是使用 apache 的 mod_rewrite 将请求重定向到带参数的 url。许多应用程序这样做是为了创建“人类可读”且对搜索引擎更友好的 URL。
例如,您可以添加此规则以使 action=sales&year=2009 看起来像 sales-2009.htm:
当用户转到“sales-2009.htm”时,它实际上使用适当的参数重定向到 php 页面。但对于最终用户来说,它仍然在浏览器的地址栏中显示 sales-2009.htm。
当然,您可以使用带 mod_rewrite 的正则表达式,这样您就可以使重定向更加灵活。例如,您可以在上面的示例中创建一个表达式,将任何年份映射到正确的参数。
The typical way of doing this is to use apache's mod_rewrite to redirect requests to the url w/ parameters. Many, many applications do this to create 'human readable' and more search engine friendly urls.
For example, you might add this rule to make action=sales&year=2009 look like sales-2009.htm:
When the user goes to 'sales-2009.htm', its actually redirected to the php page with the appropriate parameters. To the end user, though, it still displays sales-2009.htm in the browser's url bar.
You can, of course, use regular expressions w/ mod_rewrite, such that you can make the redirections much more flexible. You could, for example, make a single expression in the above example that would map any year to the correct parameter.