John
John

Reputation: 4944

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 below instead?

http://www...com/.../comments/Portugal-Crushes-North-Korea-62

Thanks in advance,

John

Upvotes: 2

Views: 101

Answers (1)

Tom
Tom

Reputation:

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.

Upvotes: 3

Related Questions