Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website and Server Administration Forum


You are currently viewing our Website and Server Administration Forum as a guest. Please register to participate.
Login



Reply
Passing a variable in htaccess redirect
Old 01-08-2011, 01:53 PM Passing a variable in htaccess redirect
Rayo's Avatar
Experienced Talker

Posts: 35
Trades: 0
Hi everyone and happy new year.
Hoping for a bit if help with this problem.
What I am trying to do is pass a variable to another page via onclick.
I have got this working except for when redirecting with htaccess.
It goes like this:
The visitor clicks a link to access a page, htaccess looks to see if the visitor has a valid cookie, if not, they are redirected to another page.
Redirection is carried out ok, but the variable is not passed or carried through to the redirected page.
Below is the relevant script and what I've tried so far.

Link script.
<a href="#" onmouseover="winopen(event,'flindex/fltemplate.html')"
onclick="window.open('http://somesite.com/html/page1.html?message=hello');">Link to file</a>

The call on page1 (which works but not when htaccess redirects)
<?php echo $_GET['message']; ?>

htaccess script
RewriteEngine On
RewriteCond %{HTTP_COOKIE} !name=500aa031ef1d5184c3b3ec821b5533de
RewriteRule .* http://somesite.com/html/otherpage.php [L]

What I've tried so far but none of them work
RewriteRule .* http://somesite.com/html/otherpage.php [L,QSA]
RewriteRule .* http://somesite.com/html/otherpage.php/$1 [R=301,L]
RewriteRule .* http://somesite.com/html/otherpage.php?id=$1 [L]
RewriteRule .* http://somesite.com/html/otherpage.php[R=301,L,QSA]

Cheers all.
Rayo
Rayo is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-08-2011, 04:10 PM Re: Passing a variable in htaccess redirect
Super Spam Talker

Posts: 880
Name: Paul W
Trades: 0
http://www.simonecarletti.com/blog/2...ing-redirects/
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE
PaulW is offline
Reply With Quote
View Public Profile
 
Old 01-09-2011, 02:03 PM Re: Passing a variable in htaccess redirect
Rayo's Avatar
Experienced Talker

Posts: 35
Trades: 0
Thanks for your input PaulW.
I've managed to get the script to pass the hello variable with a normal link on redirect, but its not working with a download link, see the example below.

<a href="#" onmouseover="winopen(event,'html/somefile.html')" onclick="window.open('http://somesite.com/html/?f=filetodownload.html?message=hello');">Link to file</a>

Any ideas appreciated.
Cheers
Rayo
Rayo is offline
Reply With Quote
View Public Profile
 
Old 01-14-2011, 10:37 PM Re: Passing a variable in htaccess redirect
Super Spam Talker

Posts: 880
Name: Paul W
Trades: 0
You have a question mark in the get string -- that's syntactically wrong. It should be an ampersand &
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE
PaulW is offline
Reply With Quote
View Public Profile
 
Old 02-28-2011, 11:38 AM Re: Passing a variable in htaccess redirect
Junior Talker

Posts: 1
Name: Jamie
Trades: 0
Quote:
Originally Posted by PaulW View Post
You have a question mark in the get string -- that's syntactically wrong. It should be an ampersand &
I don't know if this needs further breaking down but what PaulW means is, the URL's 'Query String' or 'Get String' depending on which language you use to parse the information, is the bit after .filename (.html, .php, .asp).

It is separated from the rest of the URL by a single ?, after that individual variables are further separated by a & (an ampersand).

So your URL should look like this:
http://somesite.com/html/?f=filetodownload.html&message=hello
Rather than this:
http://somesite.com/html/?f=filetodownload.html?message=hello
cjgoodwin is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Passing a variable in htaccess redirect
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15986 seconds with 12 queries