如何简化网址 [英] how to simplify the url

查看:133
本文介绍了如何简化网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Hi: In my website I found that their url are very simple like:

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

通常网址应该是:

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

也就是说没有&"组合的请求参数在网址中.

That's to say there is no request parameters combined by "&" in the url.

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

How did they make it? Is there any framework?

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

UPDATE: My application works under tomcat.

推荐答案

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

On an apache web server you can do this using mod_rewrite http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

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

Here is an example along with a tutorial...

Apache重写引擎主要用于将www.yoursite.com/product.php?id=123等动态网址转为www.yoursite.com/product/123等静态且用户友好的网址

The Apache rewrite engine is mainly used to turn dynamic url’s such as www.yoursite.com/product.php?id=123 into static and user friendly url’s such as www.yoursite.com/product/123

通过 Blogstorm SEO 博客阅读有关 htaccess 和 mod_rewrite 教程的更多信息

Read more about htaccess And mod_rewrite Tutorial by Blogstorm SEO Blog

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/ - 获得荣誉!

Read more here that example by the way is copied from http://www.blogstorm.co.uk/htaccess-mod_rewrite-ultimate-guide/ - assigned kudos!

这篇关于如何简化网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆