Couldn't get it to work...
I copied the code and stripped out the white spaces. I then included the template with the script in the application.cfm file in the root directory. I also changed the links on the page I wanted to test from directory/page.cfm?variable=#queryscope.fieldname# to directory/page.cfm/variable/#queryscope.fieldname#
After having done this, when I tested the link the page loaded very very slowly and then I got the "Page cannot be displayed" message.
Posted by: Aaron
Posted on: 04/08/2004 12:02 PM
|
FAO: Aaron
Rather than use the scrip in the application file as I have found this gets a little buggy, just include it before your queries on the page you want to use dynamically.
You also need to make sure that you are using the <base HREF> tag in your head.
Phil
Posted by: Phil Williams
Posted on: 04/16/2004 09:21 AM
|
It should work
I am not getting any errors, and including it before my queries, as well as using <base HREF>. Is there any changes I should be making to the script to get it to work, as in the site webmasteredge.com. I see it works well on this site, so this is something at my end for sure.
Posted by: Mike
Posted on: 05/08/2004 12:38 PM
|
RE: It should work
Mike,
Send me your code and I'll look it over for you.
Cheers,
Phil
Posted by: Phil
Posted on: 05/09/2004 05:40 AM
|
404
Doesn't work for me (running CFMX 6.1, on Apache 2 on RedHat Enterprise), I get a lovely 404:
404 /productsearch.cfm/ispeak=8/iwanttolearn=10
Which is what I thought would happen... Do I need to do something to the Apache config?
Posted by: Philip Tanner
Posted on: 06/24/2004 07:16 AM
|
RE: 404
You shouldn't need to make any changes to the Apache config. The one thing I noticed in your example is that you still have the = symbol in the url. Replace these with / like so: /productsearch.cfm/ispeak/8/iwanttolearn/10
That should fix you up! ;-)
Posted by: Phil Williams
Posted on: 06/28/2004 03:29 PM
|
trying to do the same with jsp application
Hi,
Would you please tell me if I can use the same script in my jsp pages to use the URLs like the above to be search engine friendly.
Thank you, Kaju
Posted by: kaju
Posted on: 07/05/2004 11:30 PM
|
re: trying to do the same with jsp application
I see no reason why this shouldn't work but I've never tried! Best thing to do is give it a whirl...
Posted by: Phil Williams
Posted on: 07/18/2004 11:17 AM
|
Awesome!!
Wow, this is great. I had some problems because I implemented the base tag incorrectly and then once i got that right everything worked perfect. I have it in my Application.cfm and have not had any bugs once I got the implementation correct.
Thank you so much,
Posted by: Adam Bragg
Posted on: 08/20/2004 01:22 PM
|
RE: Awesome
No worries! Glad you liked it...
Posted by: Phil Williams
Posted on: 08/21/2004 06:01 AM
|
This thing is AWESOME! It actually worked! You didn't even have to edit the code or take out the lines in front. But be sure to have the base href tag otherwise it might not work.
Posted by: Lola
Posted on: 09/10/2004 10:25 AM
|
Great tut, can it be expanded to do this?
Hi - I was wondering if this csscript could be expanded slightly to cover this situation: I have a hypothetical page http://www.my-site.com/index.cfm, so that when the URL is typed in http://www.my-site.com/ it goes directly to the page index.cfm. If I then try and pass the variables http://www.my-site.com/firstname/francis/lastname/saul the csscript no longer works as the valid_extensions variable is no longer applicable. I'm unfortunately not smart enough (yet :) ) to rewrite this myself.
Posted by: Francis Saul
Posted on: 09/12/2004 05:14 PM
|
notes
Looking at the code valid_extensions = "html,htm,cfm,asp,jsp";
You may think that this script will make search engine friendly urls' for all those type sof files. This is not the case as only .cfm files will run the code.
He also mentions that this causes search engine robots to trawl your site. You can easily stop this by placing a robots.txt file in your site which allows you to specify what search engines are allowed to index. Use google to find more info on this.
Posted by: Russ Michaels
Posted on: 09/18/2004 05:47 AM
|
There must be a better way!
There is a better way to make url's engine friendly. One example is: www.spain-holiday.com I know for sure that the pages are made in CF (I contacted the owner). I just can't figure out how he has done it. I have made something, you can check it on 62.131.141.237/croatiaholidayapartments
I made IIS read .cfm as .htm and then I'm capturing errors in "Missing handler templates". But this is a poor system : I can install only one error file in "missing handler templates" ...
So, if anyone knows...??? ;)
Greets from Zagreb, Croatia
Posted by: Igor
Posted on: 09/28/2004 12:16 AM
|
not working
added this before the queries and added the base href with no success. Help?
Posted by: bill foresman
Posted on: 10/06/2004 04:38 PM
|
Use with cfcache tag?
I usually cache all of my page for faster loading. I tried using the above code, and it didn't work with cfache... has anyone else tried using it with cfcache, and gotten it to work? Any ideas and/or feedback is greatly appreciated...
Posted by: Jansen Rensma
Posted on: 10/11/2004 06:41 PM
|
use with ?
This script works great except where i use <cfif isDefined("")>. Since you replace ? and = signs, there is no query string defined.
How do i get around this?
Posted by: JakeLD
Posted on: 10/13/2004 12:58 PM
|
RE: not working
Bill can you sen me a buit more information and I'll tray and help
Posted by: Phil
Posted on: 10/17/2004 03:32 PM
|
RE: use with
You cannot define the url variable so you need to use:
<cfif IsDefined("varID")> instead of <cfif IsDefined("url.varID")>
Your scripts will still wrk just as well...
Posted by: Phil
Posted on: 10/17/2004 03:33 PM
|
copy to text editor first
Sometimes, when copying from a browser, it is best to paste it into a simple text file first which strips all markup language out. Then highlight your text file and hit copy .. now try it.
( note this also works great when taking text out of say, WORD to HTML ) Just paste the stripped text into the design view of DW and your golden.
Peace. MC
Posted by: mike
Posted on: 11/10/2004 12:36 PM
|
Couldn't get it to work too!
Hi, Did everything you explained but it dose not work for me. Our site http://www.erealdeal.com/test-index.cfm?lang_id=1
Posted by: Hu
Posted on: 11/19/2004 08:19 AM
|
RE: Couldn't get it to work too!
You need to change your links so that the ?, & and = are taken out. Your example link:
http://www.erealdeal.com/test-index.cfm?lang_id=1
need to be re-written to:
http://www.erealdeal.com/test-index.cfm/lang_id/1
Posted by: Phil
Posted on: 11/21/2004 05:34 PM
|
Works but doesn't work either?
All seems to be working but the page never totally loads. By that I mean that the progress bar at the bottom of the page only ever reaches the half way mark at most. Any ideas as to why this is happening would be appreciated!
Posted by: Subway
Posted on: 01/16/2005 12:44 PM
|
Google indexing
Hi Phil,
I have spent the last couple of months implementing and testing a system to utilise this excellent script that you have written and was hoping to get some feedback about it.
You state that using this URL script will take the ?,& and "replace them all with / to make it look like folders".
However I have found the benefit of implementing this code to be non-existent, as Google indexed the ? pages anyhow but unlike Mod_Rewrite on Apache servers, this script leaves the .cfm in the URL (as you have stated - and I was aware of when starting). However I have discovered this doesn't 'trick' Search Engines into thinking the variables are folders, just a malformed URL that the script gets around by including a base href in the page. The SE's will index the pages, but they won't perform as well as pages with ? left in.
So my question is, what value is this script? Do you have any live examples of excellent Search Engine ranking pages that utilise the .cfm/variable/variable format?
Otherwise I would just recommend people to leave the ? in and to keep the number of variables in the URL to a minimum. It is just as effective (maybe the Google update at the start of the year started supporting dynamic variables better) and will be less hassle for anyone trying to build a site.
Francis Saul webmaster@experiencenz.com
Posted by: Francis Saul
Posted on: 03/15/2005 06:07 PM
|
Another advantage of using this.
Another plus of using this script is when creating html GET forms. Normally in a GET form you have to pass URL variables in hidden fields. A form with a GET method cannot pass URL variables within the action attribute.
Although, with this nifty tutorial, you can pass the URL variables in the action attribute of a GET method form, since it does not recognize the variables as part of the URL's query string.
Posted by: Lola (Matt Wegrzyn)
Posted on: 06/04/2005 04:26 PM
|
What about the URL scope??
In one of the questions you suggest that if you have <cfif IsDefined("url.varID")> we should change it to <cfif IsDefined("varID")>. What about the scope that good coding practice is to put your variables in a scope ie FROM.XXX , REQUEST.XXX etc etc??
Jonas
PS I got the script ot work OK Thanks :) DS
Posted by: Jonas
Posted on: 09/13/2005 08:30 AM
|
Good point about the URL scope
I think Jonas has got a good point about the missing URL scope issue. The only way I managed to get the script to work was to leave out the URL in the cfif statements etc.
Posted by: Neil Merton
Posted on: 10/29/2005 11:29 AM
|
Rel image hrefs
I also noticed that relative image paths break if this is used.
Hmm.
Posted by: Neil Merton
Posted on: 10/29/2005 11:31 AM
|
Run with Fusebox 4
Hello,
this script works well using 'standard' CF. But trying with Fusebox 4, it does not work. I've changed the scope of the url.var from #attributes.varname' to #varname# without success.
Do you have an idea how to get this script running with CF and Fusebox 4.
Regards, Martin
Posted by: Martin
Posted on: 01/02/2006 05:57 AM
|
Base HREF
What should the base href be set to?
Posted by: tom
Posted on: 02/23/2006 01:58 AM
|
urls anyone?
I have read through all the posts and have had issues using this format before. I do wonder how much search engine benefit is more urban legend rather than actual fact. I know that google is able to handle all forms of URLs with variables attached but as for other search engines, I can't say for sure.
I what I can say is that I find the "/" method for URLs is a "cleaner" looking method for passing vars via URL. Of course the real question is whether it really matters if it looks clean and who (other than programmers) is going to care.
My biggest concern is security. Having to worry about passing variables that someone might inject code/sql into or somehow exposing a weakness by exposing a variable name/value relationship.
Regarding issues raised here, I'll throw my 2 cents out. 1) Not working, page not found. - The issue is often that your webserver doesnt see the ".cfm" as a stop point. If there are more "/" then it thinks that there are further directories. As a result you will get a "page not found" error because it thinks that your variables are subdirectories.
There is a setting on your flavor of server software that switches this over. I don't remember what it is for IIS but I know there is a method to make it work and hopefully this gives you a place to start.
2) Images not showing. True, they won't work if you use imgage urls relative to the page they are called on because it thinks that the additional "/" indicates a location that doesnt exist and when it tries to find that image "relative" to the location that is really your variables, your going to get red "x"s.
To get arround this, use relative images but make it relative to the root of your site.
For example, your website is "www.website.com". Your images are located in "www.website.com/images". You would call on your image with a url of "/images/picture.jpg"
the "/" in front of the directory means "from the root of the site". I always use this simply because its easier to maintain. If I happen to copy-&-paste code from a different at a different level of the site, the images won't become disconnected.
Posted by: Chris Cantley
Posted on: 08/28/2007 04:50 PM
|
Moving on...
I wrote this tutorial quite some time ago now and have found there are much better methods of rewriting URLs.
My current pet favourite is using www.isapirewrite.com as we run IIS to rewrite the URLs so from http://www.domain.com/page.cfm?id=1&name=my%20product%20name to http://www.domain.com/id-1-my-product-name.cfm
Much cleaner overall and also helps with the number of actual pages indexed in Google...
Cheers,
Phil
Posted by: Philip Williams
Posted on: 09/25/2007 01:47 PM
|
Works great
It functions great for me but I am not seeing the value (yet).
Mike Herman http://www.discountitems.biz
Posted by: Mike Herman
Posted on: 10/08/2007 10:42 PM
|
A Simple Alternative
Below is crude, but is simple and it works, I think it is secure. On IIS6/CFMX7. Don't know if cgi.path_info will pass on other configurations. Clean this up and post better if you want. Or comment on security please. This is based on an alpha, not numeric query.
Needs a little work to extend it out several variables (e.g. qUrl1, qUrl2, etc.) and you can pass them to your query.
I further limit the query variable with this condition:
WHERE (Left([FIELDNAME],1) = '#qUrl#')
<code>
<cfset urllist = "#Replace(path_info, '/', ')#"> <cftry> <cfset qUrl= "#ListGetAt(urllist, 1 , '/')#"> <cfset qUrl = #URLEncodedFormat(qURL, 'UTF-8')#> <cfif Len(qUrl) is not 0> <cfset qUrl = #URLEncodedFormat(qURL, 'UTF-8')#> <cfelse> <cflocation url="<sendthemsomewhere>" addtoken="no"> </cfif> <cfcatch> <cflocation url="<sendthemsomewhere>" addtoken="no"> </cfcatch> </cftry>
</code>
Ben Montanelli
Posted by: Ben Montanelli
Posted on: 03/11/2008 09:24 PM
|