Home
Blogs
Questions
Jobs
Monetize

Home

About Us

Blogs

Questions

Jobs

Monetize

Post Job

banner

Questions about server-name

Read more about server-name

python (65.2k questions)

javascript (44.3k questions)

reactjs (22.7k questions)

java (20.8k questions)

c# (17.4k questions)

html (16.3k questions)

r (13.7k questions)

android (13k questions)

Questions - server-name

Get Sub-domain with PHP

How to get sub domain from URL. let say subdomain.example.com, then i want only subdomain Example : https://subdomain.example.com https://anything.example.com/pathurl Output : Subdomain anything Try...
test-img

Stellan Coder

php

html

regex

subdomain

server-name

Votes: 0

Answers: 4

Latest Answer

Firstly, to break down your attempt: $_SERVER['SERVER_NAME'] gives you the full server name, e.g. "subdomain.example.com" substr($_SERVER['SERVER_NAME'],0,4) gives you the first four charac...
test-img

IMSoP

Get only domain name

i want only domain name without sub domain and path URL. Example : URL loading in browser : https://www.example.com/something. I want only example.com I tried echo $_SERVER['HTTP_HOST']; and echo $_SE...
test-img

Stellan Coder

javascript

php

html

server-name

http-host

Votes: 0

Answers: 1

Latest Answer

I would make a check for the existing of "www." in the beginning of the string, and if the string starts with "www." I would remove it. Example: $domain = substr($_SERVER['SERVER_N...
test-img

thephper

Posts

Questions

Blogs

Jobs

The ultimate platform for coders and IT specialists

About

  • Company
  • Support

  • Platform

  • Terms & Conditions
  • Privacy statement
  • Cookie policy
  • Cookie option
  • OnlyCoders © 2025  |  All rights reserved