Link to home
Start Free TrialLog in
Avatar of day6
day6Flag for United States of America

asked on

SEO Friendly URL from url variables

I'm embarrassed to ask this, but I can't seem to figure out how to transition my website development method of using url variables to dynamically create the page with content but have a SEO friendly URL instead.

As it stands now, I create a template page .cfm where I use the URL variables to populate various sections of the page with dynamic content.

http://www.mysite.com/Mysite-Information.cfm?n1=some-part-of-the-page&n2=another-part-of-the-page

As I've read online, SEO standards would rather I have a subdirectory type URL instead of url variables.

http://www.mysite.com/some-part-of-the-page/another-part-of-the-page/

I honestly don't understand how I use the Mysite-Information.cfm template page and populate the content AND still have an SEO friendly URL afterward.

My mind goes back to the old days where I need literal folders on my site directory which contain duplicate versions of the template... which seems highly ridiculous to duplicate the same template over and over again.

What am I missing here? How do I get the SEO friendly URL while not having to deviate from my development method of using CFINCLUDES within the template based on CFIF statements using the URL variables as the trigger to load whatever content?
Avatar of SidFishes
SidFishes
Flag of Canada image

Simplest thing I've found is to use sesConverter http://www.erikv.com/ses/

Then when you create urls either statically

index.cfm/fuseaction/examples.testLink/sky/blue/dirt/brown/grass/green.cfm

 or on the fly

index.cfm/fuseaction/examples.testLink/sky/#url.skyvalue#/dirt/#url.dirtValue#/grass/#url.grassValue#.cfm

they end up being parsed as

index.cfm?fuseaction=examples.testLink&sky=blue&dirt=brown&grass=green

Simple, no need to mess with mod_rewrite
Avatar of day6

ASKER

Sidfishes

Honestly, not a clue what you're recommending. I looked at the markup script and don't quite understand what I'm doing here. Does the script simply read the URL that is trying to load and reload it with subdirectories? I don't get it.
You write all of your urls like so

index.cfm/sky/blue.cfm

or generate them with variables

index.cfm/sky/#variables.colour#.cfm

the sesConverter parses that into "proper" url parameters

index.cfm?sky=blue

and that is what the webserver actually sees.

Has nothing to do with subdirectories, it's  only dealing with parameters. which is what ses URLs try to handle. Subdirs generally are just written in the url normally since this is a standard part of a url

site.com/dir/subdir/index.cfm?sky=blue

site.com/dir/subdir/index.cfm/sky/blue.html
Avatar of day6

ASKER

So in my case, if my cold fusion script generates a url like

page.cfm?urlvar=#url.var1#&urlvar2=#url.var2#

You're saying I hard code in the script

page.cfm/#url.var1#/#url.var2#

Then this sesConverter intreprets all the URL calls on the fly and knows to pull in the variables right? I don't understand... does the visitor see the slashes in the URL bar or do they end up seeing the url.var in the url bar?
Almost

If you look at the SesConverter code, all it does is parse out the / in the url it receives and replaces it with ?, = and & characters (as well as the "dummy" extension should you decide to use it.)

Takes this coded url  (note that you still need the urlvar & urlvar2 as parameter names in the url)

page.cfm/urlvar/#url.var1#/urlvar2/#url.var2#

and pass it on to the CF engine as

page.cfm?urlvar=#url.var1#&urlvar2=#url.var2#

Your users  (and search engines) will see

page.cfm/urlvar/value1/urlvar2/value2

You place this in the application.cfc OnRequestStart section and it handles all the conversion before passing on so the variables can be set.
Avatar of day6

ASKER

but isn't the point of clean URL remove the url.variable in the URL itself? I mean, at present, if I have

ABC-Company.cfm?var1=About-Us-Page&var2=Staff-Directory

Doesn't a search engine see

ABC Company / About Us / Staff Directory

And index it based on the hyphenated words while disregarding the &?= signs?

I thought the point of a clean URL was to remove the variable gibberish from the URL string and if this script requires that the actual var1 and var2 remain in the cleaned up URL, wouldn't that be a pointless conversion? It doesn't look clean to have those subdirectories in the URL called /var1/

So I'm not sure I get the point of the script you're recommending. I understand it's like a Replace() function, but from a search engine standpoint, the goal is to remove the funky variable names and characters so the URL has intelligence.

I'm just not getting this.
ASKER CERTIFIED SOLUTION
Avatar of SidFishes
SidFishes
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of day6

ASKER

I never received a Cold Fusion response on this
Avatar of day6

ASKER

I've requested that this question be closed as follows:

Accepted answer: 0 points for day6's comment #a40470946

for the following reason:

This question was not answered
Uh...everything I gave you was CF and is in fact the only way to do SES using CF. If that doesn't work for you, as noted,  your option is mod_rewrite.

It might not be the solution you wanted but is not incorrect.
Avatar of day6

ASKER

Sidfishes,

Actually, the solutions you provided do NOT create SEO friendly url's as I requested. They provided a method for doing SEO friendly URL's, but not the route I requested. I do not want to have to reorganize my content into folders for the URL to work and the solutions you showed require me to change my method of site structure. I simply want a way to use what I have as url variables and have a line of code that reloads my page with a SEO friendly URL.
Yes well that's NOT possible using just CF. As I said, you need to look at mod_rewrite to do what you want.
Avatar of day6

ASKER

You provided options that do not address my request. I've posted dozens of questions on here over the years and you've actually provided me answers that have solved my issues. However, on this one, your reply is no different than some other experts on other questions I've asked where they provide a possible method that doesn't resolve my question. It certainly provides me a path to learn new coding techniques etc, but it doesn't solve the seo friendly URL without me manually recreating my site structures... which I specifically said I am not interested in doing. So your suggestions do not provide a solution based on my request. Your defacto statement of there not being a CF method to resolve it is also not 100% accurate since there haven't been any other CF experts provide input yet and this is quite an old question. I will continue to research ideas elsewhere.
Ok, perhaps I was a little inaccurate on the can't be done in CF part. There are ways to do it when using various frameworks that use a single resource point (ie: index.cfm) like FW1, Fusebox, Coldbox etc.

However, what -can't- be done is a simple drop in a block of code & go. The resource pointer methods require using the framework. There are schemes like sesConverter mentioned about which can show the client a ses url but require resource modifications. These are hacks based on the fact that CF application server can modify and pass information about a page to the webserver but the webserver is the only thing that is serving the page. It must know the resource you are trying to access.

What the CF hacks do is intercept the url and format them -back- to what your webserver needs to see to serve the resource.

This is also what mod_rewrite does but since it's integral to the webserver,  it is far more powerful and flexible.

So again, the answer to your question of how to do this without changing your methods is -you can't- with pure CF. Because what ever you do on the CF server is passed to the webserver -you can- do this using mod_rewrite.

I might point out that the reason you haven't found a google search for what you are looking for, or additional input here is that the solution you are looking for isn't available.

It can't be done -is- an answer. And based on my 15+ years of working with CF, I believe that it can't be done.