473,396 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
parameters

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

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?
Mar 6 '08 #1
3 3848
On Thu, 06 Mar 2008 16:45:38 +0100, WebCM <we******@gmail.comwrote:
How to apply nice URL-s into CMS?
Apache mod_rewrite (ask in alt.apache.configuraion if you run into
troubles.
1. Should we use nice urls for every page?
Preferably, yes.
2. Do we need to put a FULL path into <a href="">?
Depends, if content can change location/hierarchy, yes, that is to say,
use <a href="/path/to/something/">, not <a href="../something/">. You
don't need the http and domain portion in it.
3. What is faster and better?

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

b) one rule in .htaccess and parsing "nice url" in PHP (strpos,
explode...).
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 highly
on the logic used, I'd say: try it out.
4. Do search engines still deal with "nice urls" better than with
normal URLs in 2008?
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 for
humans (guessable & rememberable URLS, certainly a plus when for instance
advertising in print, but in a browser context also a plus.)
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?
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.
Why are "nice urls" better than normal?
- 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
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?
Depends on the actual goal, I just feed the path portion of
$_SERVER['REQUEST_URI'] directly into a query which gives me the page used
from a Nested Set Model table. Has some overhead, but most sites I workon
are complex enough to benefit from it.
--
Rik Wasmus
Mar 6 '08 #2
WebCM wrote:
1. Should we use nice urls for every page?
"Nice things are nicer than nasty ones."
-- _Lucky Jim_, Kingsley Amis.
2. Do we need to put a FULL path into <a href="">?
I tend to use a root-relative path (i.e. one starting with "/").
3. What is faster and better?

a) 10 rules in .htaccess which redirect you to normal URLs with GET
parameters
b) one rule in .htaccess and parsing "nice url" in PHP (strpos,
explode...).
Which is faster? Probably not much difference. mod_rewrite rules in
httpd.conf will beat both though.

I tend to just redirect all requests (except a few specific directories
for CSS files, images, downloads, etc) to "index.php/*" and then PHP logic
can deal with them.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 37 days, 18:16.]
[Now Playing: Ed Harcourt - The Trapdoor]

Bottled Water
http://tobyinkster.co.uk/blog/2008/02/18/bottled-water/
Mar 7 '08 #3
IMPORTANT: URLs like index.php/something/after may not work. It
depends on server configuration. If admin disable PATH_INFO, URLs like
this will cause 404 error.
Mar 8 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: Howard Brazee | last post by:
I would like to click on a URL of a html document that will open several URLs at once for me. Does someone have an example of a html document that will do this?
0
by: Kunle Odutola | last post by:
I'd like to access a few docs in the VS.NET help collection from a .NET app. The obvious WebClient/WebRequest/WebResponse solution isn't working because their is no pluggable protocol...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
11
by: Stef Mientki | last post by:
hello, Is there some handy/ nice manner to view the properties of some variable ? As a newbie, I often want to see want all the properties of a var, and also some corner values (large arrays)...
169
by: JohnQ | last post by:
(The "C++ Grammer" thread in comp.lang.c++.moderated prompted this post). It would be more than a little bit nice if C++ was much "cleaner" (less complex) so that it wasn't a major world wide...
5
by: stdazi | last post by:
Hello, Yesterday, I was at a programming competition. We programmed on Linux liveCD's and Python was one of the allowed languages (among C and Java). I cared just about the algorithmic approach...
4
by: k3pp0 | last post by:
Hey. I've got a very basic newbie question, I hope you can understand me. Sorry for asking it, first of all. I see a lot of sites (e.g. communities) with a url-structure like this:...
4
by: Guy Macon | last post by:
As a personal learning experience with limited practical use, I have been doing some experiments with using .htaccess to redirect mis-typed URLs to a preferred canonical form. I have set up a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.