做一个URL重写 [英] Doing a URL Re-Write
问题描述
当我点击了一个网站,我有一个定条目的注释部分,网址如下:
<$p$p><$c$c>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
在此先感谢,
约翰·
您想看看这个:
http://www.addedbytes.com/for-beginners / URL重写换初学者/
据你从来没有做过。我发现它非常有用。
您会希望这样的事情(在根目录下的.htaccess文件):
RewriteEngine叙述上
?重写规则^评论/([A-Z0-9 _] +)/([0-9] +)$的index.php 1提交= $&放大器; submissionid = $ 2 [L]
我会用 HTTP://www...com/。 ../comments/Portugal_Crushes_North-Korea-62
而不是HTTP://www...com/ ... /评论/葡萄牙,击碎 - 北 - 韩国 - 62
会更容易使用。
When I click on a comment section for a given entry on a site I have, the URL looks like this:
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
How can I make it look like the URL below instead?
http://www...com/.../comments/Portugal-Crushes-North-Korea-62
Thanks in advance,
John
You want to look at this:
http://www.addedbytes.com/for-beginners/url-rewriting-for-beginners/
It you've never done it before. I've found it very useful.
You would want something like this (in a .htaccess file in the root directory):
RewriteEngine On
RewriteRule ^comments/([a-z0-9_]+)/([0-9]+)?$ index.php?submission=$1&submissionid=$2 [L]
I would use http://www...com/.../comments/Portugal_Crushes_North-Korea-62
instead of
http://www...com/.../comments/Portugal-Crushes-North-Korea-62
Would be easier to work with.
这篇关于做一个URL重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!