Rudy Hartanto
Rudy Hartanto

Reputation: 17

How to get value 127.0.0.1 rather than ::1 on php

I want to get value 127.0.0.1 when do $_SERVER['REMOTE_ADDR']. But instead getting 127.0.0.1. I get value ::1. Anyone can help me how to get that value? Used it for log activity.

Upvotes: 0

Views: 2341

Answers (1)

chandresh_cool
chandresh_cool

Reputation: 11830

::1 is an IPv6 address and an abbreviation for 0:0:0:0:0:0:0:1 that is the loopback address to the local machine. So ::1 is the same as 127.0.0.1 only via IPv6 instead of IPv4.

If you really just want IPv4, try to disable IPv6 connections in your apache configuration:

Listen 0.0.0.0:80
Listen 192.170.2.1:80

You can find detailed solution here

Upvotes: 3

Related Questions