generate functionWed, 09 Nov 2022

php if current url is subdomain name 'media', redirect to main domain

<?php $host = $_SERVER['HTTP_HOST']; // example: dev.example.com $host = explode('.', $host); $host = $host[0]; if($host == 'media'){ header('Location: http://www.example.com', true, 301); exit(); } ?>

Questions about programming?Chat with your personal AI assistant