Try this:
if (substr($_SERVER['HTTP_HOST'], 0, 4) === 'www.') {
header('Location: http'.(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on' ? 's':'').'://' . substr($_SERVER['HTTP_HOST'], 4).$_SERVER['REQUEST_URI']);
exit;
}
More Related Contents:
- PHP store hours, closed dates [closed]
- Cannot modify header information [duplicate]
- How can I find where I will be redirected using cURL in PHP?
- PHP generate file for download then redirect
- PHP Session timeout
- How to create an error 404 page using PHP?
- PHP Redirect to another page after form submit
- Redirecting to previous page after login? PHP
- How to get the real URL after file_get_contents if redirection happens?
- PHP Redirection with Post Parameters
- php get url of redirect from source url
- PHP header(Location: …): Force URL change in address bar
- Redirect to page and send custom HTTP headers
- Back to previous page with header( “Location: ” ); in PHP
- cURL , get redirect url to a variable
- Laravel 5.4 redirection to custom url after login
- nginx redirect loop, remove index.php from url
- Change WordPress Admin URL
- Redirect with PHP after ajax call
- PHP Header Redirect in a new window?
- Redirect after Login on WordPress
- How to redirect back to form with input – Laravel 5
- What is the best way to notify a user after an access_control rule redirects?
- how to redirect domain according to country IP address
- How to redirect to the same page in PHP
- Redirecting WordPress’s Login/Register page to a custom login/registration page
- Redirect to ‘www’ before ssl requirement
- How to cause a redirect to occur before php script finishes?
- Warning: file_get_contents: failed to open stream: Redirection limit reached, aborting
- .htaccess – Redirect subdomain to folder