Search Engine-Friendly URLs

This is an article discussion thread for discussing the SitePoint article, “Search Engine-Friendly URLs

try out this one for mod rewrite:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*/)?([^/]+)/([^/]+) $1?$2=$3&%1 [L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^.*$ index.php?%1 [L]

It recursively iterates over the request and replaces ‘field/val/’ with ‘field = val’. I don’t know if it is technically SEO index friendly or not though.

I have tried method 2 a number of times. It works well but the irony is, pages using this method are not indexed by search engines.

Search Engine Friendly? hmmm

I have checked a couple on unimportant sites which have been live for over a year and only the static pages ending with .php are indexed, the dynamic stuff is not.

Also Google Webmaster Tools reports each dynamic page as a 404 error.

And most auto sitmap generating tools also report these pages as errrors and usually fail to include them in their output.

Looks like I’m gonna have to try mod-rewrite.

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.

Yes, I used it when I converted everything from ASP to PHP. VERY useful. 10/10

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

Prefer mod_rewrite here as well.

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.

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?

Good article, and to confirm it’s usefulness doing a search for ‘article 485’ on google will give this article as the first result :slight_smile:

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

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?

Your forgot a big drawback:
$_GET and $_POST will be ignored with redirections!

Why not explain the method of mod_rewrite with apache?

Is there a way to use any one of those methods on a IIS server?

There is Ivan! Called IISRewrite.
However you can easily make that (php only) methods with ASP… if that’s your case.

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.

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

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.