Jump to content

Modrewrite


Kon-Tiki

Recommended Posts

Hey, the site I got now's finished, so I wanted to add some polish to it by adding user-friendly URLs (which might help solving a small Javascript-detection related imperfection and a minor bug that comes along with it). I know how to do mod-rewrites (got a clean example file from the time I figured it out), but this is less a technical issue.In short, I have near to none experience with mod-rewrite. I figured out how it works, technically, and used it once on a previous site I made. Purely the technical part's no problem, as I got the example file and there's plenty of regex references online. What the problem is, though, is the following.The site itself's main focus is on projects. In the current URL, the projects are listed by ID, not project name. This has two reasons:1) It's just easier and cleaner to put an ID in an URL parameter (whitespace, special chars, etc issue is gone)2) Laziness from my part (turning the way the site handles these things around to use project name instead of ID)As far as user-friendly URLs go, putting just the ID in isn't exactly useful. Who knows what project they'll come to when they go to http://www.mysite.com/en/42 ? It'd be alot more userfriendly to be http://www.mysite.com/en/someproject (the EN being language).So, the main questions are these:1) Is there a user-friendly way to use the ID?2) If not using the ID, is there a way to cleanly and elegantly handle whitespaces, special chars, etc? (meaning that people don't have to fill in http://www.mysite.com/en/some%20project, for example)Thanks in advance,Kon-Tiki

Link to comment
Share on other sites

You can create special clean "slugs" for each project title that replaces special characters into hyphens, so "some project" becomes "some-project" and "some:things & more" becomes "some-things-more". Then you store that in the DB and use them for links, e.g. http://www.mysite.com/en/some-project

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...