Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

URL aliases in emails

0.00/5 (No votes)
6 Nov 2002 1  
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
%>

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here