当我点击我所拥有的网站上给定条目的评论部分时,网址如下所示:
http://www...com/.../comments/index.php?submission=Portugal%20Crushes%20North%20Korea&submissionid=62&url=nytimes.com/2010/06/22/sports/soccer/22portugalgame.html?hpw&countcomments=3&submittor=johnjohn12&submissiondate=2010-06-21%2019:00:07&dispurl=nytimes.com
如何让它看起来像下面的网址?
http://www...com/.../comments/Portugal-Crushes-North-Korea-62
提前致谢,
约翰
答案 0 :(得分:3)
你想看看这个:
http://www.addedbytes.com/for-beginners/url-rewriting-for-beginners/
你以前从未这样做过。我发现它非常有用。
你会想要这样的东西(在根目录的.htaccess文件中):
RewriteEngine On
RewriteRule ^comments/([a-z0-9_]+)/([0-9]+)?$ index.php?submission=$1&submissionid=$2 [L]
我会使用http://www...com/.../comments/Portugal_Crushes_North-Korea-62
而不是
http://www...com/.../comments/Portugal-Crushes-North-Korea-62
更容易使用。