I am working on a website that is redirecting users based on their IPs.
I have installed the same copy of the website on two different servers. One is using the HTTP protocol, and the other one is using the HTTPS protocol.
The website with HTTP server is recording IPv6 for some users but when the same user from the same mobile visits the website which is on the HTTPS server, the website records IPv4.
I have the following questions:
Is there any relation between https, ipv4, and ipv6?
No. HTTPS does not care about the underlying IP protocol. It can be done both on top of IPv4 and IPv6.
Is there a way that the server always records IPV4 and not IPV6?
What you see is likely due to a different configuration of the sites. For the site where you only see IPv4 traffic there might be no AAAA (IPv6) record in DNS or HTTPS is not configured properly on the web server but only IPv4 is (common problem) so that the client simply cannot use IPv6.