URL aliases in emails





5.00/5 (1 vote)
Nov 7, 2002

69414
How to use URL aliases to fix for the URL wrapping problem in emails
Introduction
Don't you hate it when you receive emails with links like the one below ? Imagine how your customers feel about it.
Hi,
Look at the new program I just finished:
http://soderlind.no/this-is-a-very-long-path/with-a-subdirectory/file.as
p?var1=value1&var2=value2&var3=a-verly-long-value
Br,
Per
You can easily fix this by creating an URL alias, and send a mail like this one:
Hi,
Look at the new program I just finished:
http://soderlind.no/u/?CP001
Br,
Per
To handle URL aliases on your server, do the following:
- 1st, create a virtual directury on your server: /u
- 2nd, save the code below as default.asp in the virtual directory, and modify it with your URLs
<%@LANGUAGE="VBSCRIPT"%>
<%
Option Explicit
Const DEFAULTURL = "http://soderlind.no/"
Dim dUrlRedir,strKEY
Set dUrlRedir = CreateObject("Scripting.Dictionary")
'
' Add as many as you wish. If you are going to have a lot of aliases,
' you should consider storing then in a database
'
dUrlRedir.add "CP001", "http://soderlind.no/this-is-a-very-long-path/with-a-" & _
"subdirectory/file.asp?var1=value1&var2=value2&var3=a-verly-long-value"
dUrlRedir.add "CP002", _
"http://www.codeproject.com/aspnet/cassini_apache_101.asp"
dUrlRedir.add "CP003", _
"http://www.codeproject.com/useritems/xpwebdevfriendly.asp"
'//
If Not IsEmpty(request.ServerVariables("QUERY_STRING")) Then
strKEY = request.ServerVariables("QUERY_STRING")
If dUrlRedir.Exists(strKEY) Then
response.Redirect(dUrlRedir(strKey))
Else
response.Redirect(DEFAULTURL)
End If
Else
response.Redirect(DEFAULTURL)
End If
%>