65.9K
CodeProject 正在变化。 阅读更多。
Home

电子邮件中的 URL 别名

starIconstarIconstarIconstarIconstarIcon

5.00/5 (1投票)

2002 年 11 月 7 日

viewsIcon

70249

如何使用 URL 别名来修复电子邮件中的 URL 换行问题

引言

你是否讨厌收到像下面这样的包含链接的电子邮件?想象一下你的客户会有什么感受。

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

你可以很容易地通过创建URL别名来解决这个问题,并发送像这样的邮件

Hi,
Look at the new program I just finished: 
http://soderlind.no/u/?CP001


Br,
Per

为了在你的服务器上处理URL别名,请执行以下操作

  • 首先,在你的服务器上创建一个虚拟目录:/u
  • 其次,将下面的代码保存为default.asp到虚拟目录中,并用你的URL进行修改
<%@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", _
  "https://codeproject.org.cn/aspnet/cassini_apache_101.asp"
dUrlRedir.add "CP003", _
  "https://codeproject.org.cn/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
%>
© . All rights reserved.