HOWTO: Redirigir web
En este ejemplo, para forzar acceso usando "www" al inicio del dominio.
1. Via programación, usando PHP:
if ($_SERVER["SERVER_NAME"] != 'www.example.org' ) {
header('Location: http://www.example.org' . $_SERVER['REQUEST_URI']);
exit();
}
header('Location: http://www.example.org' . $_SERVER['REQUEST_URI']);
exit();
}
2. En VirtualHost de Apache
<VirtualHost 192.168.0.1:80> ServerName example.org Redirect 301 / https://www.example.org/ </VirtualHost>
CategorySysAdmin