Want to change URL pattern

2019-02-16 04:00发布

问题:

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.

回答1:

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.



回答2:

What you want is Apache's mod_rewrite

Check this out: apache.org



标签: url