liltyga
asked on
Redirecting pages
Hi,
I'm trying to find out what the most efficient way is to redirect to pages in this scenario:
The initial website for one of my clients was built in HTML. The client doesn't want the customer to get to a "page not found" error if users access the old urls once the new site goes live.
I really don't want to just add a meta or javascript redirect in all of the old pages, and keep them on the server, and was wondering if anyone knows of a script that could possibly reside in the application.cfm file or if I need to put a redirect in a custom 404 error file on IIS.
The only problem with the custom 404 error is that I don't think that I can use CF code on that page, and I need to be able to redirect to a specific page based on the page the user is trying to access (ie, the equivalent .cfm page for the previous .htm page), and if the page didn't previously exist, have the solution redirect to the main index page.
Does that make sense? If so, can anyone offer a suggestion?
I'm trying to find out what the most efficient way is to redirect to pages in this scenario:
The initial website for one of my clients was built in HTML. The client doesn't want the customer to get to a "page not found" error if users access the old urls once the new site goes live.
I really don't want to just add a meta or javascript redirect in all of the old pages, and keep them on the server, and was wondering if anyone knows of a script that could possibly reside in the application.cfm file or if I need to put a redirect in a custom 404 error file on IIS.
The only problem with the custom 404 error is that I don't think that I can use CF code on that page, and I need to be able to redirect to a specific page based on the page the user is trying to access (ie, the equivalent .cfm page for the previous .htm page), and if the page didn't previously exist, have the solution redirect to the main index page.
Does that make sense? If so, can anyone offer a suggestion?
You really should not fool around with the 404 page, you need to use redirects from within IIS, as it returns the proper status code back to the browser, i.e. a "page moved" = 303 or something, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
Trust me if you fool around with the 404 error page you will run into trouble at a later stage.
Trust me if you fool around with the 404 error page you will run into trouble at a later stage.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi 8riaN,
good one :-)
Regards,
---Pinal
good one :-)
Regards,
---Pinal
Hi,
I'm trying to find out what the most efficient way is to redirect to pages in this scenario:
The client want to display user friendly URLs like:
http://www.mywebsite.com/city/state/country/mypage.cfm
without creating the directories on server in actual .
I really don't want to just add a meta or javascript redirect or install any IIS extension, and was wondering if anyone knows of a script that could possibly reside in the application.cfm or application.cfc file . I dont want to put a redirect in a custom 404 error file on IIS.
Does that make sense? If so, can anyone offer a suggestion?
I'm trying to find out what the most efficient way is to redirect to pages in this scenario:
The client want to display user friendly URLs like:
http://www.mywebsite.com/city/state/country/mypage.cfm
without creating the directories on server in actual .
I really don't want to just add a meta or javascript redirect or install any IIS extension, and was wondering if anyone knows of a script that could possibly reside in the application.cfm or application.cfc file . I dont want to put a redirect in a custom 404 error file on IIS.
Does that make sense? If so, can anyone offer a suggestion?
you can create virtual directories within the website
There are only a few choices I'm aware of:
1) a URL rewriting extension (best solution) like this: http://www.seoconsultants.com/windows/isapi/ or this: http://www.smalig.com/url_rewrite-en.htm
But you said no extensions.
2) Tacobell's virtual directory suggestion. In that case the IIS Admin must set up a virtual directory for every state and county which points to somewhere.
3) A custom 404 page.
In the case of 2 or 3 above, you then would parse the Incoming URL to decide what to do next.
But shouldn't this be a new question?
8riaN
1) a URL rewriting extension (best solution) like this: http://www.seoconsultants.com/windows/isapi/ or this: http://www.smalig.com/url_rewrite-en.htm
But you said no extensions.
2) Tacobell's virtual directory suggestion. In that case the IIS Admin must set up a virtual directory for every state and county which points to somewhere.
3) A custom 404 page.
In the case of 2 or 3 above, you then would parse the Incoming URL to decide what to do next.
But shouldn't this be a new question?
8riaN
Open the CF Adminstrator and in "Server>Server Settings>Settings" set the missing template handler to your home page (or whatever).
Open IIS and set the 404 handler for the site (or the virtual directory, or whatever) to a local URL, starting from the webroot, say "/custom404.cfm"
put code like this into custom404.cfm:
<cfset defaultURL="index.cfm"><!-
<cfset errCode=GetToken(QUERY_STR
<cfset newURL=defaultURL>
<cfif errCode NEQ "404">
Something's rotten in Denmark <!--- If you set up IIS correctly, this would only happen if somebody browsed straight to custom404.cfm --->
</cfif>
<cfset originalURL=GetToken(QUERY
<cfif originalURL NEQ "">
<cfset parseURL=REFindNoCase("(.*
<cfif ArrayLen(parseURL.pos) GT 1>
<cfset newURL=mid(originalURL,par
</cfif>
</cfif>
<cflocation url="#newURL#"><!--- if this doesn't exist, the cf engine will just pass them to the home page. --->
Q.E.D.
8riaN