Read URL and create array after slash
<?php $str = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; $res = array_filter(explode("/", $str)); //echo $res[0]; if ($res[0] == "condition") { // do something } ?>