473,583 Members | 3,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"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 3861
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.conf iguraion 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
12460
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
1098
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 implementation for "ms-help" included in the framework as standard. Does such an implementation exist somewhere?. Failing that, has anyone been able to do...
1
6466
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" setting to be "E_ALL", notices are still not getting reported. The perms on my file are 664, with owner root and group root. The php.ini file is located...
11
1524
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) etc. Probably it's not so difficult, but I don't see how to distinguish for example between a string and an array. An array has a shape, a string...
169
9002
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 untaking to create a toolchain for it. Way back when, there used to be something called "Small C". I wonder if the creator(s) of that would want to...
5
1203
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 so I used Python. One of the main rules is, that the code reads its standard input and dumps the result on the standard output. Here happened my...
4
3284
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: example.com/users/paul (displaying the user profile of "paul") or example.com/pictures/landscapes/13 (displaying pictures from the category "landscapes", page...
4
4863
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 test page at http://www.guymacon.org/test.html ] to show the results of my testing. Most of the URLs redirect as I want them to do, but the three...
0
8184
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8328
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7936
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8195
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6581
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5701
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3845
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2334
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1434
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.