Go Back   SitePoint Forums > Forum Index > Program Your Site > PHP
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Aug 5, 2004, 12:37   #1
ArticleBot
SitePoint Articles
 
ArticleBot's Avatar
 
Join Date: Apr 2001
Posts: 0
Article Discussion

This is an article discussion thread for discussing the SitePoint article, "Search Engine-Friendly URLs"
ArticleBot is offline   Reply With Quote
Old Aug 5, 2004, 13:14   #2
stymiee
He's No Good To Me Dead
 
stymiee's Avatar
 
Join Date: Feb 2003
Location: Slave I
Posts: 24,090
This article is old but still very relevant. Implementing what I learned in this article has had a profound impact on my websites. To score it a 10 would be to under-rate its value.
stymiee is offline   Reply With Quote
Old Aug 5, 2004, 23:42   #3
mrWoot
SitePoint Zealot
 
mrWoot's Avatar
 
Join Date: Jan 2004
Location: Wisconsin
Posts: 132
Yes, I used it when I converted everything from ASP to PHP. VERY useful. 10/10
mrWoot is offline   Reply With Quote
Old Aug 6, 2004, 04:47   #4
dklynn
Hosting
SitePoint Award Recipient
 
dklynn's Avatar
 
Join Date: Feb 2002
Location: Auckland
Posts: 10,687
IMHO, Chris Beasley missed the best solution (and gets, at best, a 6/10 for his effort).

Sitepoint's Apache forum has MANY good threads on using Apache's mod_rewrite module in the .htaccess file. With this, I've just completed transitioning from a series of $_GET style URLs to Search Engine Optimized pages (i.e., the http://www.domainname.com/article/## displays the /viewfullarticle?id=## script). There were some knotty things to work out but I believe this is far superior to Chris's path_info, Error Pages and ForceType. Anyone interested in SEO should have a read of Chris's article then have a search through the Apache forum for mod_rewrite (online documentation on mod-rewrite is terrible -- that forum has provided the best information I've found).

Regards,

DK
dklynn is offline   Reply With Quote
Old Aug 6, 2004, 07:40   #5
expert_21
SitePoint Enthusiast
 
Join Date: Nov 2003
Location: earth
Posts: 89
Prefer mod_rewrite here as well.
expert_21 is offline   Reply With Quote
Old Aug 10, 2004, 11:22   #6
siliconsorcerer
SitePoint Member
 
Join Date: Aug 2004
Location: Illinois, USA
Posts: 2
forcetype application

Have used this and prefer it, however it appears busted in http 2.0

www.site.com/script involkes the (or even a script with symlinks
enabled to script.php but

www.site.com/script/parms doesn't even get envolked anymore ?

Was using
<location
which maybe should have/be
<file

but neither works now.

Any suggestions?
siliconsorcerer is offline   Reply With Quote
Old Aug 10, 2004, 11:35   #7
siliconsorcerer
SitePoint Member
 
Join Date: Aug 2004
Location: Illinois, USA
Posts: 2
Quote:
Originally Posted by siliconsorcerer
Have used this and prefer it, however it appears busted in http 2.0

www.site.com/script involkes the (or even a script with symlinks
enabled to script.php but

www.site.com/script/parms doesn't even get envolked anymore ?

Was using
<location
which maybe should have/be
<file

but neither works now.

Any suggestions?
Oh man nothing like being a dope....
Looks like AcceptPathInfo on is the answer.
siliconsorcerer is offline   Reply With Quote
Old Aug 27, 2004, 17:14   #8
saiena
SitePoint Member
 
Join Date: Aug 2004
Location: 93402
Posts: 1
Fircetype Solution Seems Incompatible with Web Log Tools

I've used the Forcetype solution, and have become aware that Web Log tools (e.g., LiveStats) can not report page activity, because none of my URLs end in file extensions.

Any advice?
saiena is offline   Reply With Quote
Old Jan 24, 2005, 22:30   #9
cranial-bore
SitePoint Wizard
 
cranial-bore's Avatar
 
Join Date: Jan 2002
Location: Australia
Posts: 2,092
Good article, and to confirm it's usefulness doing a search for 'article 485' on google will give this article as the first result :)
cranial-bore is offline   Reply With Quote
Old Feb 5, 2005, 19:17   #10
Saidan Ryuuza
SitePoint Community Guest
 
Posts: n/a
None of these methods work for me, the apache "look back" feature doesnt work on three different servers, what am i doing wrong?

thanks

email:webmaster@therandomjoe.com
ICQ: 165512867 (prefered)
AIM: sryuuza
MSN: sryuuza@msn.com
  Reply With Quote
Old Feb 10, 2005, 03:37   #11
djdykes
SitePoint Evangelist
 
djdykes's Avatar
 
Join Date: Feb 2005
Location: Preston, Lancs
Posts: 561
the only thing missing in this article is what the links should become! as a novice i struggled as the links kept altering. other then that seems to work fine. any one got any tips how to add security to these methods?
djdykes is offline   Reply With Quote
Old Feb 28, 2005, 03:51   #12
bob
SitePoint Community Guest
 
Posts: n/a
Your forgot a big drawback:
$_GET and $_POST will be ignored with redirections!
  Reply With Quote
Old Mar 5, 2005, 08:26   #13
xmitchx
SitePoint Evangelist
 
Join Date: Jun 2004
Location: California
Posts: 440
Why not explain the method of mod_rewrite with apache?
xmitchx is offline   Reply With Quote
Old Mar 24, 2005, 13:03   #14
Ivan
SitePoint Community Guest
 
Posts: n/a
Is there a way to use any one of those methods on a IIS server?
  Reply With Quote
Old Apr 30, 2005, 23:29   #15
gesf
SitePoint Enthusiast
 
gesf's Avatar
 
Join Date: Oct 2004
Location: Portugal
Posts: 43
There is Ivan! Called IISRewrite.
However you can easily make that (php only) methods with ASP... if that's your case.
gesf is offline   Reply With Quote
Old May 6, 2005, 12:31   #16
mrsocks
SitePoint Member
 
Join Date: May 2005
Posts: 2
Is this even nessesary anymore?
Don't most search engines index and follow the whole URL anyway now?

I do agree that the url looks cleaner, but to go through the trouble of reqwritting what i have, am i going to get a noticeable impovement in ranking?

thanks.
mrsocks is offline   Reply With Quote
Old May 6, 2005, 13:56   #17
spikeZ
dooby dooby doo
 
spikeZ's Avatar
 
Join Date: Aug 2004
Location: Manchester UK
Posts: 11,067
You should notice an improvement in SE rankings but also bear in mind your visitors.
It is far easier to type www.mydomain.com/site than www.mydomain.com/site/id=1&template=id...... etc
spikeZ is online now   Reply With Quote
Old May 20, 2005, 13:00   #18
Malambo
SitePoint Community Guest
 
Posts: n/a
If the site is designed with ease of navigation in mind, the user won't need to type the URL anyway. Optimally, visitors should be able to get to an in depth article within three clicks from the home page.
  Reply With Quote
Old Jul 25, 2005, 03:22   #19
Ultrapasty
SitePoint Community Guest
 
Posts: n/a
Still, if possible it's probably better to stay on the safe side ;) I think that's the route I'll be taking!

Thanks for this article, I found it really useful.
  Reply With Quote
Old Jul 30, 2005, 18:23   #20
technel
SitePoint Enthusiast
 
Join Date: Apr 2004
Location: Minnesota, USA
Posts: 62
I just wanted to comment on two things:

1.) Seriously, if you are making some sort of dictionary or resource website that is based around searches, allow the user to type in http://example.org/query_here. I must say, that is the most annoying part of Wikipedia for me. Let me type it in myself! I wish dictionary.com would do that also. PHP.net does it wonderfully, just go to php.net/include, and the include() function reference page pops up!

2.) Some people might want to head over to drupal.org and look at their .htaccess file. They used an interesting technique for achieving URLs like this. They basically have everything after the domain name and slash rewritten to ?q=. Therefore, you could type http://example.org/article/215, and explode() the / out of there, call the article function, and then fetch the id 215. Or you could have pages like http://example.org/aboutus and http://example.org/donate without having to create files for all of them (as in the 3rd method mentioned above).
technel is offline   Reply With Quote
Old Sep 29, 2005, 03:18   #21
Steve
SitePoint Community Guest
 
Posts: n/a
There is a drawback to these types of URL... Yahoo sucks... Yahoo likes to drop the last traing slash and then concatenate directories - using the above examples, a request from Slurp might be

/article/999/12article/999/article12/999

It sounds crazy I know, but I have spent weeks trying to "retrain" Slurp because of this exact problem, only to find it dropping the trailing slash on the retrained URLs

A further complication is that Slurp makes up queries for example /article/?id=123, where the id 123 does not exist in any way on your site.

So much fun :(
  Reply With Quote
Old Dec 29, 2005, 17:09   #22
Aaron D.
SitePoint Addict
 
Join Date: Dec 2005
Posts: 257
In my personal experience the mod_rewrite works far better than the other options. I originally used an error page to parse the variables from the names of html files similar to the way you described however occasionally IE had problems and would display its own 404 page. So I settled into using mod_rewrite.
Originally I tried using a directory structure for the rewrites but it was causing trouble with my relative links, so I decided to use the name of a html file to pass the variables the same way as I did in the error method. This way there would be no hanging directories which make it obvious variables are being passed and it left the pages with easy to remember names.

If anyone is interested I used the following rewrite rule:
RewriteBase /
RewriteRule ^([a-zA-Z]+).html$ index.php?mode=$1

This way my entire website appears to be a bunch of static pages while giving me the ease of using a single file.
Aaron D. is offline   Reply With Quote
Old Jan 8, 2006, 02:09   #23
risqer
SitePoint Member
 
Join Date: Oct 2004
Location: Mumbai
Posts: 13
Just wondering why Sitepoint chose PATH_INFO method over mod_rewrite. Is there any specific reason for this decision?
risqer is offline   Reply With Quote
Old Jan 13, 2006, 13:59   #24
Hector
SitePoint Community Guest
 
Posts: n/a
Thank you for the ideas. The ForceType Directive method works great for my site. I was able to nest the script and now I'll never need to use those silly ?'s in the URL's again.

The only problem I encountered was the first value of the array. In your example,

$var_array = explode("/",$PATH_INFO);

produces:

$var_array[0] = "article.php"

$var_array[1] = 999

$var_array[2] = 12

But when I ran the same code on my server, $var_array[0] always returned blank. It's not a problem, just curious as to why this could be happening.

Thanks again!
  Reply With Quote
Old Jan 27, 2006, 23:55   #25
a8
SitePoint Community Guest
 
Posts: n/a
maybe your server disable register global
  Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 10:48.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved