<?php $url = 'https://developer.hyvor.com/tutorials'; preg_match('#^(?:\w+://)?([^/]+)#i', $url, $matches); echo $matches[1];