Go Back   WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk
Register Blogs FAQ Social Groups CalendarHelp Desk

Reply
 
LinkBack Thread Tools
Old 01-23-2010, 03:54 PM   #1
FirebirdSEO.com
War Room Member
 
Jeff Scott's Avatar
 
Join Date: Sep 2009
Location: Phoenix, AZ
Posts: 285
Thanks: 3
Thanked 51 Times in 34 Posts
Social Networking View Member's Twitter Profile  View Member's YouTube Profile
Default Answer this PHP question and I'll Paypal you $5

** The first person to post the solution to this, I'll PM you to get your Paypal address and I'll send you $5

QUESTION: I'm trying to figure out the best way to redirect a vistitor who types in my URL with a coupon code (see below) to another url with a variable populated. For example, when someone types the following:

http://www.mysite.com/A101

they are redirected to:

http://www.mysite.com/page.php?coupon=A101 (PREFERRED SOLUTION)

or to:

http://www.mysite.com where a form field is prepoulated with the A101 code so they only need to click a submit button

Right now the mysite.com/A101 is treated as a 404 and I tried to do a custom PHP to get the URL using SERVER_NAME and PHP_SELF but it's just showing the 404.php page. I don't want to have to create files/directories for A101 anywhere, it needs to dynamically do it.

I'm running on Apache/PHP

Thanks in advance!

Jeff Scott is offline   Reply With Quote
Old 01-23-2010, 04:08 PM   #2
HyperActive Warrior
War Room Member
 
tjs1954's Avatar
 
Join Date: Aug 2009
Location: Port Charlotte, Florida
Posts: 204
Thanks: 45
Thanked 20 Times in 18 Posts
Default Re: Answer this PHP question and I'll Paypal you $5

Jeff,

When I want a browser to leave one site and go to another I just put this code in the meta tags of the index page, <meta HTTP-EQUIV="REFRESH" content="0; url=http://www.yourdomain.com/index.html"> or whatever page you want it to go to.

The zero is how many seconds you want it to wait before it switches.
tjs1954 is offline   Reply With Quote
Old 01-23-2010, 04:18 PM   #3
Thinker
 
Trey Walter's Avatar
 
Join Date: Sep 2009
Location: Germany
Posts: 61
Thanks: 54
Thanked 9 Times in 7 Posts
Social Networking View Member's Twitter Profile 
Default Re: Answer this PHP question and I'll Paypal you $5

Hi Jeff,

you can also use URL rewriting to do that. (I think this would be the best solution if there are a lot of different coupon codes.)

Here's how to do it:
mod_rewrite: A Beginner's Guide to URL Rewriting [Apache & IIS Configuration]

Trey

Trey Walter is offline   Reply With Quote
Old 01-23-2010, 04:35 PM   #4
FirebirdSEO.com
War Room Member
 
Jeff Scott's Avatar
 
Join Date: Sep 2009
Location: Phoenix, AZ
Posts: 285
Thanks: 3
Thanked 51 Times in 34 Posts
Social Networking View Member's Twitter Profile  View Member's YouTube Profile
Default Re: Answer this PHP question and I'll Paypal you $5

Quote:
Originally Posted by tjs1954 View Post
Jeff,

When I want a browser to leave one site and go to another I just put this code in the meta tags of the index page, <meta HTTP-EQUIV="REFRESH" content="0; url=http://www.yourdomain.com/index.html"> or whatever page you want it to go to.

The zero is how many seconds you want it to wait before it switches.
Yes, that is how I typically do simple redirects, but what I'm trying to do is a bit more complicated than that.

Jeff Scott is offline   Reply With Quote
Old 01-23-2010, 11:30 PM   #5
PHP Programmer
 
m4rx's Avatar
 
Join Date: Nov 2009
Location: /dev/null
Posts: 136
Thanks: 5
Thanked 12 Times in 12 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile  View Member's YouTube Profile
Contact Info
Send a message via Skype™ to m4rx
Default Re: Answer this PHP question and I'll Paypal you $5

Well I would with what Trey said.
You could use mod_rewrite to redirect your page.

Make a file called .htaccess and have the contents be:
RewriteEngine on
RewriteRule ^yourURL$ /page.php?coupon=yourURL [R]

and whenever someone types in yoursite.com/yourURL they will be redirected to the page.php?coupon=yourURL

You can see a demo by typing m4rx.com/coupon and it will so you the redirect to cat.php?coupon=coupon

This is just like when companys do this. You could modify it to show R=301(Found). This is the industry standard and works well.
http://en.wikipedia.org/wiki/HTTP_302
Don't use 301(Moved Permanatly) as then the URL becomes useless when crawled, and because I would rarely use it(except after major remodeling ;] ).

Any help configuring it, PM me.
--m4rx

We are what we repeatedly do. Excellence, then, is not an act, but a HABIT. ~Aristotle
Bored. Check out my blog.

Last edited by m4rx; 01-23-2010 at 11:33 PM. Reason: Added redirect type code
m4rx is offline   Reply With Quote
Old 01-25-2010, 08:20 AM   #6
Customer Tools
War Room Member
 
Join Date: Dec 2009
Location: Texas
Posts: 96
Thanks: 0
Thanked 7 Times in 7 Posts
Social Networking View Member's Twitter Profile  View Member's YouTube Profile
Default Re: Answer this PHP question and I'll Paypal you $5

m4rx has the solution I would choose. unless you want to modify the php code. (which would be very easy to do)

Ultimate Keyword Tool - Create HUGE Targeted Keyword Lists In Minutes Not Hours Or Days. $7 seven day trial.
customertools is offline   Reply With Quote
Old 01-25-2010, 08:59 AM   #7
Warrior Member
 
Join Date: Oct 2009
Location: Warsaw, Poland
Posts: 11
Thanks: 7
Thanked 4 Times in 3 Posts
Default Re: Answer this PHP question and I'll Paypal you $5

Nice idea with Paypal. It might be useful sometimes...

rukki is offline   Reply With Quote
Old 01-25-2010, 09:07 AM   #8
FirebirdSEO.com
War Room Member
 
Jeff Scott's Avatar
 
Join Date: Sep 2009
Location: Phoenix, AZ
Posts: 285
Thanks: 3
Thanked 51 Times in 34 Posts
Social Networking View Member's Twitter Profile  View Member's YouTube Profile
Default Re: Answer this PHP question and I'll Paypal you $5

Quote:
Originally Posted by Trey Walter View Post
Hi Jeff,

you can also use URL rewriting to do that. (I think this would be the best solution if there are a lot of different coupon codes.)

Here's how to do it:
mod_rewrite: A Beginner's Guide to URL Rewriting [Apache & IIS Configuration]

Trey
Hey Trey,

Thanks for pointing me in the right direction...mod rewrites seems like the way to go. I'll PM you for your Paypal address to send you the $5!

- Jeff

Jeff Scott is offline   Reply With Quote
Reply

  WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk

Tags
answer, paypal, php, question

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -6. The time now is 04:10 AM.