Forum Moderators: mack
I want to do a variable data direct mailing with URL's on each postcard e.g. www.example.com/davestraight.htm; www.example.com/bobsmith.htm, www.example.com/tigerwoods.htm etc.
So first I need a way to quickly create all these pages from a csv file or the like.
Each page has to be a template that includes the person's name within it and if possible, a couple other pieces of variable data.
My 1st question is, how can I create all of these pages quickly that have the /personsname.htm or /personsname
My second question is how can I create this template page that will contain the variable data?
Any help would be appreciated or who to turn to for help as well.
Thanks,
David
[edited by: encyclo at 11:23 am (utc) on Dec. 7, 2007]
[edit reason] switched to example.com [/edit]
If the content is generally the same, just with a few parts modified to personalise it, it'd be easiest for you to use a Query String instead.
eg. http://www.example.com/custompage.html?name=bobsmith
or http://www.example.com/custompage.html?name=tigerwoods
That way you are only needing to create one page (custompage.html) that will service every person you want to send it to and they will each have a unique URL that is trackable in web stats programs.
Then depending on which language you are using, you can grab that query string from the URL by looking for the 'name' part.
ie. in PHP
$urlname = $_GET['name'];
or in ASP
Dim urlName
urlName = Request.QueryString("name")
Then you can modify the page according to what was contained in the new variable - in this case urlName.
[edited by: Kikikins at 6:54 am (utc) on Dec. 6, 2007]
[edited by: encyclo at 11:22 am (utc) on Dec. 7, 2007]
[edit reason] switched to example.com [/edit]
example.com/BobSmith
You put a mod_rewrite directive in your .htaccess file that redirects anything not a file and not a directory to your script. In the code below, this message board tries to correct our "bad grammar" by removing the space before the exclamation point - a space is required before "!":
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^(.*)$ /path_to/your_script [L]
So now, "your script" strips off the end of the query string and looks it up in a database. That is, with your programming you take the query string and extrapolate everything after the last slash,* and store only "BobSmith"
$member_url='BobSmith';
select * from members where url='$member_url';
Then proceed to output the pages dynamically, but it looks like a static page. In the member database you would have values that indicate which template to use, color preference settings, whatever - without ever creating a single static page.
The thing to watch out for here is it messes up your 404 (not found) scheme, so when nothing is found in the database you have to be careful to output a 404 header and direct to a page that indicates not found - redirecting to a main page is confusing, and search engines need to know when it's a 404.
The other thing is the!-f and!-d method uses more resources than other methods, but you have to have a pretty big site to bog it down using this approach.
*If you use adWords, it will often add an "?" at the end - example.com/BobSmith?sdsdfssa.... in which case you take only the part after the last slash and before the "?".
As pointed-out above, the way to go is a dynamic page using the scripting language of your choice, mod_rewrite, and possibly a database backend.
-----
I'd be more concerned about how your users are going to feel about the violation of their privacy. I hope it's at least opt-in.
I'd sure be hopping mad if a postcard (not even a sealed envelope!) arrived in the mail announcing that somebody else had created a web page with my name on it.
While the content may not contain any personal details other than their name, and may be perfectly innocuous, it connects the user publicly with your site/the page. Not so good if either is NOT perfectly innocuous, personal or embarrassing in any way, etc.
It would feel just plain creepy to get that post card, in any case.