0

I want to get the full website URL from a given domain name using PHP.

example.com

I want the actual full URL which exists like one of the below.

http://example.com
http://www.example.com
https://example.com
https://www.example.com
Aminul
  • 25
  • 4
  • Does this answer your question? [Get the full URL in PHP](https://stackoverflow.com/questions/6768793/get-the-full-url-in-php) It's not completely clear what you're looking for. Are you saying you know the domain is `example.com`, but you essentially want to know where you are redirected after entering that in your browser? – WOUNDEDStevenJones May 27 '22 at 17:25
  • If I provide "example.com" or "google.com" then I want to get the full root URL that actually exists when enter in the browser. – Aminul May 28 '22 at 03:59
  • Then you'll need to make a request to that domain and see where you end up. There's no way for you to know if `example.com` redirects to `https://subdomain.other-example.net` or not, unless you make the request and trace it until you get a valid webpage (HTTP 200, not 301 or 302, etc). Also, there's not always just 1 "actual full URL". For example, web server can be configured to serve the same content from `example.com` or `www.example.com`. – WOUNDEDStevenJones May 28 '22 at 20:07

0 Answers0