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

product names in the URL

Participant ,
Feb 13, 2008 Feb 13, 2008

Copy link to clipboard

Copied

Hi

I am developing an shopping cart. If the user enterers the product name in the url, i want to display the product. rather than using the product ID. like

http://www.mysite.com/book
http://www.mysite.com/pen
http://www.mysite.com/computers

rather than http://www.mysite.com/product.cfm?productid=3.

how would i do this...I am using the IIS 6 and CF8.

Regards
Srinivas

TOPICS
Advanced techniques

Views

724

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

correct answers 1 Correct answer

Advocate , Feb 14, 2008 Feb 14, 2008
garyrgi touched base on what I was talking about. I had to do this on our main www.shift4.com when we updated it. The problem was that we didn't want to loose all the search engine links when various template names changed or were consolidated.

I wrote a 404.cfm template. In it I created a big list template names specifying the old name and the new name (actually I use an xml document to define this and I also have a parameter of whether to use cflocate vs. dish it out directly using cfinclude ...

Votes

Translate

Translate
Engaged ,
Feb 13, 2008 Feb 13, 2008

Copy link to clipboard

Copied

Generally speaking, there are two steps involved in doing something like that.

Step 1: create a new .cfm page that accepts product-names in the URL (instead of ID). E.g...
http://www.mysite.com/productByName.cfm?productname=book

Step 2: install and configure a URL "rewrite" module on your web server. You can then configure a single re-write rule that maps all subdirectory requests to "productByName.cfm?productname=<SUBDIR>"

If you're using Apache as your web server, you can take a look at the mod_rewrite module:
http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

Alternatively, if you're using Microsoft IIS as your web server, you can take a look at the ISAPI_Rewrite module:
http://www.isapirewrite.com/

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
Participant ,
Feb 14, 2008 Feb 14, 2008

Copy link to clipboard

Copied

Presentyl i am using the IIS6.
can i do a sample in my local system. I using my PC as test environement. If i can able to do this in my local system then i can upload the same to production.

Srinivas

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 ,
Feb 13, 2008 Feb 13, 2008

Copy link to clipboard

Copied

You may be able to do what you're asking if you plug in your own 404 error template. The this template would have the "intelligence" to direct the customer to the appropriate native page.

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
Participant ,
Feb 14, 2008 Feb 14, 2008

Copy link to clipboard

Copied

Steve,

I did not get you what you are saying.

Srinivas

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
Explorer ,
Feb 14, 2008 Feb 14, 2008

Copy link to clipboard

Copied


I wrote a blog entry that details a method of doing what you are trying to do.

http://www.garyrgilbert.com/blog/index.cfm/2008/1/2/Coldfusion-Mod-Rewrite

I also have an example somewhere if you need it after reading my blog entry let me know

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 ,
Feb 14, 2008 Feb 14, 2008

Copy link to clipboard

Copied

garyrgi touched base on what I was talking about. I had to do this on our main www.shift4.com when we updated it. The problem was that we didn't want to loose all the search engine links when various template names changed or were consolidated.

I wrote a 404.cfm template. In it I created a big list template names specifying the old name and the new name (actually I use an xml document to define this and I also have a parameter of whether to use cflocate vs. dish it out directly using cfinclude or cfcontent -- this way even pdf's or other documents can be found as well).

If I find the template called in the old list, I do whatever action I need to do to send the user to the new location or present the information to the user from the new location. If I don't find a match, then I take the user to our site map with a message that the file requested was not found.

The only tricky part is that in IIS or whatever server you use, somewhere there is a 404 template setting -- you'll need to point this to your 404.cfm template.

It works. Try any of the following links -- both do exactly what I just described (I also pasted my corresponding xml definition just to give you an idea of what I am doing):

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
Participant ,
Feb 14, 2008 Feb 14, 2008

Copy link to clipboard

Copied

LATEST
Hi Gary

thanks for posting, i will look into this idea. I have seen your blog. I feel the idea is good. but i need to test it.

Srinivas.

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