Redireccionar directorio raíz de un url a una subcarpeta sin que el url cambie
Estaba buscando solución al siguiente problema:
¿Cómo hacer que una subcarpeta sea la raíz en mi dominio?
Es decir, quería que www.midominio.com apuntara a www.midominio.com/subcarpeta pero de tal forma que el usuario nunca se diera cuenta.
La solución la encontré en el foro de discusión de Drupal: drupal.org/node/188023.
Básicamente lo que hay qué hacer es crear un archivo .htaccess en el directorio raíz con las siguientes líneas (sustituyendo "yourdomain.com" y "subfolder" con mi nombre de dominio y carpeta correspondiente):
# .htaccess main domain to subfolder 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
# Change yourdomain.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
# Change 'subfolder' to be the folder you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subfolder/
# Don't change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subfolder' to be the folder you will use for your main domain.
RewriteRule ^(.*)$ /subfolder/$1
# Change yourdomain.com to be your main domain again.
# Change 'subfolder' to be the folder 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.)?yourmaindomain.com$
RewriteRule ^(/)?$ subfolder/index.php [L]
- admin's blog
- Login to post comments
