开发者

Doing a URL Re-Write

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 belo开发者_Python百科w 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜