"Nice URLs" - how to implement it in PHP?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

How to apply nice URL-s into CMS?

1. Should we use nice urls for every page?

2. Do we need to put a FULL path into <a href="">?

3. What is faster and better?

a) 10 rules in .htaccess which redirect you to normal URLs with GET

b) one rule in .htaccess and parsing "nice url" in PHP (strpos,

4. Do search engines still deal with "nice urls" better than with
normal URLs in 2008?

5. When we must put more parameters into GET and only some of them
occurs in one request - should we place them in "nice url" or should
we better do something like: index.php/nice/url?param=value?

Why are "nice urls" better than normal? How to implement them in CMS?
Example path:

- example.com/pathtosite/index.php/art/50
- example.com/pathtosite/art/50

Are they correct? So...

$_URL = explode(...); - good solution?

Or maybe some rules for the most important pages are enough and we
don't need to parse URLs in PHP?

Re: "Nice URLs" - how to implement it in PHP?

Quoted text here. Click to load it

Apache mod_rewrite (ask in alt.apache.configuraion if you run into  =


Quoted text here. Click to load it

Preferably, yes.

Depends, if content can change location/hierarchy, yes, that is to say, =

use <a href=3D"/path/to/something/">, not <a href=3D"../something/">. Yo=
u  =

don't need the http and domain portion in it.

Quoted text here. Click to load it

b) is certainly more flexible (and is what I use), but has some overhead=

as you delegate a lot ot 401's to PHP. Which one is faster depends highl=
y  =

on the logic used, I'd say: try it out.

Quoted text here. Click to load it

They do a lot better with 'not nice urls' then they used to, however,  =

having the actual keyword(s) searched for in the URL is definitly a plus=
.  =

And you don't only change the URRLS's for the search engine, but also fo=
r  =

humans (guessable & rememberable URLS, certainly a plus when for instanc=
e  =

advertising in print, but in a browser context also a plus.)

Quoted text here. Click to load it

If you can change it to keywords searched for, having them in the path  =

portion has it's advantages. It they don't hold easily guessable  =

parameters interpretable by humans, just use the query string.

Quoted text here. Click to load it

- Better scoring on keywords.
- Not related to the actual type of script or technology used (php, .NET=
,  =

Perl, Python), so it's easier to maintain the same URLs for all content,=

even after a major refactoring ('nice urls don't change')
- Guessable by humans
- Easy to remember by humans

Quoted text here. Click to load it

Depends on the actual goal, I just feed the path portion of  =

$_SERVER['REQUEST_URI'] directly into a query which gives me the page us=
ed  =

 from a Nested Set Model table. Has some overhead, but most sites I work=
 on  =

are complex enough to benefit from it.
-- =

Rik Wasmus

Site Timeline