【问题标题】:how to simplify the url如何简化网址
【发布时间】:2010-12-25 06:54:04
【问题描述】:

嗨: 在我的网站中,我发现他们的网址非常简单,例如:

http://example.com/questions/4486620/randomaccessfile-probelm

一般来说,网址应该是这样的:

http://example.com/questions?xx=4486620&title=randomaccessfile-probelm

也就是说url中没有“&”组合的请求参数。

他们是怎么做到的?有没有框架?

更新: 我的应用程序在 tomcat 下运行。

【问题讨论】:

  • 如果您指明运行网站的服务器以及运行网站的应用程序,您会得到更好的答案。运行 php 的 apache 服务器和运行 Asp.Net 的 IIS 服务器处理这个问题的方法是不同的。
  • 谢谢,我在 tomcat 下运行我的应用程序。

标签: url url-rewriting


【解决方案1】:

在 apache 网络服务器上,您可以使用 mod_rewrite http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html 执行此操作

这是一个示例和一个教程...

Apache 重写引擎主要用于将动态 url,例如 www.yoursite.com/product.php?id=123 转换为静态和用户友好的 url,例如 www.yoursite.com/product/123

阅读更多关于 Blogstorm SEO 博客的 htaccess 和 mod_rewrite 教程

RewriteEngine on
RewriteRule ^product/([^/\.]+)/?$ product.php?id=$1 [L]
Another example, rewrite from:
www.yoursite.com/script.php?product=123 to www.yoursite.com/cat/product/123/

RewriteRule cat/(.*)/(.*)/$ /script.php?$1=$2

在此处阅读更多内容,顺便说一下,该示例是从 http://www.blogstorm.co.uk/htaccess-mod_rewrite-ultimate-guide/ 复制而来的 - 已获得荣誉!

【讨论】:

  • IIS 有一个类似的解决方案,ISAPI_Rewrite。它有一个免费的精简版。
  • 酷,我不知道 IIS 的重写。
  • IIS URL Rewrite 2.0 是微软的官方插件及其免费iis.net/download/urlrewrite
猜你喜欢
  • 2011-02-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-18
  • 2013-07-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多