SEO Friendly URLs

Dancook

Distinguished Member
Hey all,

I've been looking into creating SEO friendly URLs.

It's an Apache/Coldfusion website, I have found you can use Apache's mod_rewrite to rewrite urls from say

yourdomain.com/product.cfm?category=books&product=23

into this.
yourdomain.com/product/books/23

But what methods do I have to rewrite the URL into
yourdomain.com/product/books/harry-potter-and-the-dangerous-pebble

Can this be done at Apache level, it would need to know how to get the title, is this possible?

Or will I have to do it at Coldfusion level?
 

Achy

Established Member
I'm guessing that the products are coming from a database.
If not you **could** do it at Apache level, but you'd have to set up the rewriter for every product :thumbsdow

So you're be better off using a combination of both...

yourdomain.com/product/books/harry-potter-and-the-dangerous-pebble

becomes

yourdomain.com/product.cfm?category=books&product=harry-potter-and-the-dangerous-pebble

Then use Coldfusion to select the product from the database that matches the title supplied by the "product" element in the url.
Or... look at the url of *this* page for example ... it combines the threadid with the thread title.

So in your example it would become...
yourdomain.com/product/books/23-harry-potter-and-the-dangerous-pebble

You could then use the apache rewrite with a regex to select the first numbers to use as the product id.
 
Last edited:

Dancook

Distinguished Member
The links aren't all dynamic, so I can't populate existing links with the "product title", unless I pass it through a page to add it...

but then if i'm passing it through a page to add it - then that page could just create the friendly URL.

Though I'm not sure on the best way of doing that currently.
 

Dancook

Distinguished Member
Ok I haven't found a definitive guide yet..but here's the logic I think I need to follow, correct me if i'm wrong

URL.cfm?id=xxxxx

redirects to

/url/id-title/

Which goes to a 404 error handler, which then 'includes' the original page.

This way you get to keep your special URL in the address bar right..
 

Dancook

Distinguished Member
I think I can wrap this up now, I'm going to consider writing these files so they actually exist in the new directory structure.

If anyone then enters on id= it will redirect to the 'static' page, which just includes the dynamic page.

As long as the technical services team don't see any performance issues with this :) then it's probably a go.
 

The latest video from AVForums

Amazon Fire TV Cube Gen 3 Review: Coming Soon
Subscribe to our YouTube channel
Support AVForums with Patreon

Top Bottom