views:

58

answers:

1

Hello,

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

+3  A: 

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.

Thanks... that link is a good intro. I have two questions: After I've come up with some Rewrite Rules that work, will I then go and change all of the hyperlinks in the site to make them link to the clean version of the URL? Also, I noticed that your example does not have all of the info that I am passing along using the GET method... does the clean version of the URL need to have all of the info / variables in the messy version of the URL?
John
I just did it as a quick example. You can put them in if you want. But if your using the id to get that information on the page the url goes too then i wouldn't have thought so.
You should tick this answer if its right. As I'm pretty sure it answered your question.