• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ColdFusion URL Re-write

New Here ,
Nov 15, 2006 Nov 15, 2006

Copy link to clipboard

Copied

Is it possible to re-write a URL query into a more search engine friendly string with ColdFusion. I know this is possible with .NET and PHP, but haven't found a way to do it using ColdFusion yet.
TOPICS
Advanced techniques

Views

985

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 15, 2006 Nov 15, 2006

Copy link to clipboard

Copied

What have you tried? In CF, you can access CGI.PATH_INFO, which is what's populated when you request a URL like:
http://www.mysite.com/index.cfm/foo/bar/baz
In this case, CGI.PATH_INFO would contain "/foo/bar/baz"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 15, 2006 Nov 15, 2006

Copy link to clipboard

Copied

I want to change the way the actualy URL looks to the search engine. For example, a user search for a product and the broswer sends a query string to the server, soemthing like http://www.ennisproducts.com/cfmx/products/prodType.cfm?PRODTYPE_NUM=17&SECTION_NUM=6&SECTION_NAME=B...

But instead of that long, nasty URL, I want is to be soemthing like http://www.ennisproducts.com/cfmx/products/BATTERY+CABLES

There is a way to do this on the fly but I dont know where to start.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 15, 2006 Nov 15, 2006

Copy link to clipboard

Copied

Well, you can make it look like this:
http://www.ennisproducts.com/cfmx/products/prodType.cfm/PRODTYPE_NUM/17/SECTION_NUM/6/SECTION_NAME/B...
or if you assume the order of the parameters, you can make it look like this:
http://www.ennisproducts.com/cfmx/products/prodType.cfm/17/6/BATTERY+CABLES

Then on prodType.cfm, you use CGI.PATH_INFO and break it into a list with "/" as the delimiter. The first value is your PRODTYPE_NUM, 2nd is SECTION_NUM, and 3rd is SECTION_NAME.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 16, 2006 Nov 16, 2006

Copy link to clipboard

Copied

LATEST
It's not a matter of the language you use, but of the server. Use Mod-rewrite on Apache and Isapi_rewrite on IIS.

Isapi_rewrite can be found at:
http://www.isapirewrite.com/

Rules are then written in a http.ini file in the root of the (virtual) site, your example could be rewritten to:

http://www.ennisproducts.com/17/6/battery+cables.htm

with this rule:

RewriteRule /(\d+)/(\d+)\/([^/?]+).htm /cfmx/products/prodType.cfm\?PRODTYPE_NUM=$1&SECTION=$2&SECTION_NAME=$3 [I,L]

Regards,
Paul

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation