sypder
asked on
Tracking IP change from HTTP to HTTPS
We track users on our website based on IP address, and lately we have noticed some incorrect tracking information. I believe this is because when someone switches from http to https their IP address changes. Is it possible to append this line in .htaccess to have the old IP address. Here is what I have now:
# switch to httpS if secure directory resources requested using http
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^secure/(.*)$ https://www.thenaughtybag.com/secure/$1 [R=301,L,NE]
I would want something like
# switch to httpS if secure directory resources requested using http
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^secure/(.*)$ https://www.thenaughtybag.com/secure/$1<& or ?>{REMOTE_ADDR} [R=301,L,NE]
Thanks
# switch to httpS if secure directory resources requested using http
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^secure/(.*)$ https://www.thenaughtybag.com/secure/$1 [R=301,L,NE]
I would want something like
# switch to httpS if secure directory resources requested using http
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^secure/(.*)$ https://www.thenaughtybag.com/secure/$1<& or ?>{REMOTE_ADDR} [R=301,L,NE]
Thanks
ASKER
Thanks routinet. Because this is only in our final checkout stage, I don't think we will have that many IPs, so having overlap shouldn't be a big problem.
How can I do <& or ?> in .htaccess, otherwise is the code I have above correct?
How can I do <& or ?> in .htaccess, otherwise is the code I have above correct?
You'll want to use the [QSA] modifier for the RewriteRule. Check it out at:
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriterule
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriterule
ASKER
My question has never answered. I know how to use the rewrite rule. (I use it in my question). My question has how to control wether a & or a ? is used in the rewrite rule.
>>> My question has never answered.
Did you read my last response? More importantly, did you read the information found at the link I provided? Even more importantly, did you read the section of the [QSA] modifier found at the link I provided?
Did you read my last response? More importantly, did you read the information found at the link I provided? Even more importantly, did you read the section of the [QSA] modifier found at the link I provided?
ASKER
I don't see how it would work in this situation.
Can you give me an example?
RewriteRule ^secure/(.*)$ https://www.thenaughtybag.com/secure/$1<& or ?>{REMOTE_ADDR} [R=301,L,NE,QSA]
Can you give me an example?
RewriteRule ^secure/(.*)$ https://www.thenaughtybag.com/secure/$1<& or ?>{REMOTE_ADDR} [R=301,L,NE,QSA]
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Okay,
This is what I didn't get. I didn't know that QSA was smart enough to relieze that after {REMOTE_ADDR} that it needed to start with a & and not a ?
Thanks.
This is what I didn't get. I didn't know that QSA was smart enough to relieze that after {REMOTE_ADDR} that it needed to start with a & and not a ?
Thanks.
You most certainly could append the original IP to a rewrite request, but I don't think that will help you much in this regard. There are no guarantees that the new IP is the exact same user since a proxy will handle requests from potentially thousands of people.