Want to change URL pattern

2019-02-16 03:21发布

These days, I've seen a URL pattern like this:

http://stackoverflow.com/questions/How-to-do

Not a usual and old one like this:

http://stackoverflow.com/questions.php?id=123

or

http://stackoverflow.com/questions.php?q=How-to-do

As you know, the difference is that the former is using / directory pattern, and the latter is using ?key=value&key=value....

I guess it's something to do with server config. My language is JAVA and PHP, and Web container is TOMCAT6. Please teach me how to change URL patter. Because it looks more organized and brand new.

Thank you.

标签: url
2条回答
可以哭但决不认输i
2楼-- · 2019-02-16 03:48

What you want is Apache's mod_rewrite

Check this out: apache.org

查看更多
Root(大扎)
3楼-- · 2019-02-16 04:03

URL Rewriting can be achieved with PHP on Apache using the Apache mod_rewrite plugin and a rule definitions placed in a .htaccess file. Here's a guide.

On Tomcat 6 there is a popular URL rewriting utility called UrlRewrite.

查看更多
登录 后发表回答