Click here to Skip to main content
15,897,371 members
Articles / Programming Languages / ASP
Article

URL aliases in emails

Rate me:
Please Sign up or sign in to vote.
4.00/5 (1 vote)
6 Nov 2002 69.2K   26   10
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
VBScript
<%@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


Written By
Web Developer
Norway Norway
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Generalwww.tinyurl.com Pin
Anonymous7-Nov-02 9:30
Anonymous7-Nov-02 9:30 
GeneralRe: www.tinyurl.com Pin
Cypher7-Nov-02 23:58
Cypher7-Nov-02 23:58 
GeneralRe: But now you have to... Pin
Per S7-Nov-02 8:27
Per S7-Nov-02 8:27 
QuestionVulnerability? Pin
Derek Lakin7-Nov-02 2:56
Derek Lakin7-Nov-02 2:56 
AnswerRe: Vulnerability? Pin
Per S7-Nov-02 3:11
Per S7-Nov-02 3:11 
AnswerRe: Vulnerability? Pin
Paul Watson7-Nov-02 8:35
sitebuilderPaul Watson7-Nov-02 8:35 
GeneralRe: Vulnerability? Pin
Per S7-Nov-02 8:42
Per S7-Nov-02 8:42 
AnswerRe: Vulnerability? Pin
Anonymous8-Jan-03 10:41
Anonymous8-Jan-03 10:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.