PHP redirect based on HTTP_HOST/SERVER_NAME within same domain

reockeque

New Member
I am trying to redirect to a specific path based on HTTP_HOST or SERVER_NAME with a PHP-script.I have tried these scripts:1. \[code\]$domain = $_SERVER["SERVER_NAME"];if (($domain == "example.dk") || ($domain == "www.example.dk")) { header("location: /index.php/da/forside"); }?>\[/code\]2. \[code\]switch ($host) { case 'example.dk': header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.example.dk/index.php/da/forside/"); exit(); case 'www.example.dk': header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.example.dk/index.php/da/forside/"); exit(); default: header("Location: http://www.example.se"); exit(); }?>\[/code\]And other similar scripts. Either the page loads forever or the browser returns some redirection error.
 
Back
Top