I'm trying to track visitors who come to my site through a vanity domain that I set up years ago. What I'm trying to do is set a cookie so that I can track them. here is the code I have:
<?
if (!isset($_COOKIE["Redirect"])) {
setcookie("Redirect", "Yes", time()+60*60*24*365, "/");
}
header("HTTP/1.1 301 Moved Permanently");
header("Location: [
domain.com...]
exit();
?>
This script gets called from an Apache rewrite rule. They would enter on www.vanitydomain.com and Apache does an internal rewrite to my script.
The problem is that the cookie gets created in the www.vanitydomain.com domain and not www.domain.com. I've tried moving the create cookie statements after the redirect and it still doesn't work right. Now I realize that I could add a query parameter to the end of the redirected url and pick up on it that way, but I don't want to redirect the domain to a page with a query parameter as that may be seen as a duplicate page.
Any ideas?
Thanks,
Mark