Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- "Nice URLs" - how to implement it in PHP?
March 6, 2008, 3:45 pm
rate this thread
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?
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?
Apache mod_rewrite (ask in alt.apache.configuraion if you run into =
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=
don't need the http and domain portion in 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=
on the logic used, I'd say: try it out.
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=
humans (guessable & rememberable URLS, certainly a plus when for instanc=
advertising in print, but in a browser context also a plus.)
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.
- 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
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=
from a Nested Set Model table. Has some overhead, but most sites I work=
are complex enough to benefit from it.