[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Tracking IP change from HTTP to HTTPS

Posted on 2007-08-08
9
Medium Priority
?
280 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:sypder
  • 4
  • 4
8 Comments
 
LVL 51

Expert Comment

by:Steve Bink
ID: 19658656
If someone's IP address is changing, it is not likely to be because they are using SSL vs non-SSL.  They are most likely using a proxy server (like AOL) to browse the web.  In this scenario, their IP could change to anything from one connection to the next, and there is not really a feasible way to track it 100%.

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.  
0
 
LVL 3

Author Comment

by:sypder
ID: 19658696
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?
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 19658977
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
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
LVL 3

Author Comment

by:sypder
ID: 19848565
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.
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 19850794
>>> 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?


0
 
LVL 3

Author Comment

by:sypder
ID: 19851129
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]
0
 
LVL 51

Accepted Solution

by:
Steve Bink earned 2000 total points
ID: 19851332
RewriteRule ^secure/(.*)$ https://www.thenaughtybag.com/secure/$1?{REMOTE_ADDR} [R=301,L,NE,QSA]

To quote from the manual (emphasis is added):

'qsappend|QSA' (query string append)
This flag forces the rewrite engine to append a query string part of the substitution string to the existing string, instead of replacing it. *******Use this when you want to add more data to the query string via a rewrite rule.*******

Also:

Note: Query String

The Pattern will not be matched against the query string. Instead, you must use a RewriteCond with the %{QUERY_STRING} variable. You can, however, create URLs in the substitution string, containing a query string part. Simply use a question mark inside the substitution string, to indicate that the following text should be re-injected into the query string. When you want to erase an existing query string, end the substitution string with just a question mark. To combine a new query string with an old one, use the [QSA] flag.
0
 
LVL 3

Author Comment

by:sypder
ID: 19851349
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.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month18 days, 19 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question