Archive for noviembre 2013

h1

Apache: alojar varios dominios en una cuenta de hosting

19/11/2013

Actualización de octubre de 2026. Este artículo documenta reglas de .htaccess para una cuenta de alojamiento compartido. No todas las plataformas permiten esta configuración. Si controlas el servidor web, puede resultar más claro configurar virtual hosts o bloques de servidor independientes que crear reglas de reescritura complejas.

Antes de modificar reglas, realiza una copia del archivo y revisa posibles bucles de redirección, el certificado HTTPS, la ruta de cada aplicación y su URL canónica. Comprueba también que los dominios apuntan correctamente al alojamiento.

Relacionado: activar mod_rewrite y revisar .htaccess y recargar Apache.


Si se desea tener diversos dominios en una misma cuenta de hosting, es necesario a parte de tener configuradas las DNS adecuadamente, tener en la raíz del hosting si utiliza Apache la siguiente configuración en el fichero «.htaccess» 

 

 # .htaccess main domain to subdirectory redirect
        # Copy and paste the following code into the .htaccess file
        # in the public_html folder of your hosting account
        # make the changes to the file according to the instructions.
        # Do not change this line.
        RewriteEngine on

# INICIO DOMINIO1 # Change example.com to be your main domain. RewriteCond %{HTTP_HOST} ^(www.)?example.com$ # Change 'subdirectory' to be the directory you will use for your main domain. RewriteCond %{REQUEST_URI} !^/subdirectory/ # Don't change these line. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Change 'subdirectory' to be the directory you will use for your main domain. RewriteRule ^(.*)$ /subdirectory/$1 # Change example.com to be your main domain again. # Change 'subdirectory' to be the directory you will use for your main domain # followed by / then the main file for your site, index.php, index.html, etc. RewriteCond %{HTTP_HOST} ^(www.)?example.com$ RewriteRule ^(/)?$ subdirectory/index.html [L]
#FIN DOMINIO 1
#INICIO DOMINIO 2
(...)

Reemplazando «example.com» por el dominio en cuestión y «subdirectory» por el subdirectorio que lo albergará. Repetir el bloque de directivas por cada dominio.

 

Fuente: https://my.hostmonster.com/cgi/help/347