'global variables for 301 redirect dim gb301redirect,_ 'true/false - true = 301 redirect must be performed gs301redirectprotocol,_ 'secured (https://) = port 443 or unsecured = port 80 gs301redirecthost,_ 'the redirect host (or domain) gs301redirectpathandscript,_ 'the path (sub directories) and script name gs301redirectqs,_ 'the url parameters or query string gs301homehost 'default host name (only relevant if you have 'multiple domains pointing to one website) gs301homehost = "mysite.com" Call sysdetermine301redirhostandprotocol() Call syscheckisprimaryhost() if gs301redirectpathandscript = "" then gs301redirectpathandscript = request.servervariables("SCRIPT_NAME") end if gs301redirectqs = request.querystring if request.querystring("afid") <> "" then 'Your custom tracking code where you log hits for each afid, set a cookie etc. '.... end if 'Remove afid tracking URL parameter from Querystring gs301redirectqs = RemoveFromQueryStr(gs301redirectqs, "afid") 'if afid was found in querystring, gb301redirect is set to true if gb301redirect = true then Call sysexec301redirect() end if