Hola que tal, quiero que mi dominio se redireccione a www pero solamente el dominio, los subdominios tambien se redireccionan... Es extraño, a lo largo del dia he estado configurando y a veces han redireccionado a www.sub.dominio.tk y otras a www.sub.dominio.tk/sub y ahora despues de estar todo el dia probando me sale el mensaje de firefox diciendo que esta redirigiendo de una manera en la que nunca terminará o el error 500 Internal Server Error (pero creo que esto es del hosting que a veces lo suelta)
Este es el .htaccess:
Citar<IfModule mod_rewrite.c>
RewriteEngine On
# WWW Redirection
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.{HTTP_HOST}/$1 [R=301,L]
# Tell PHP that the mod_rewrite module is ENABLED.
SetEnv HTTP_MOD_REWRITE On
# Dont redirect direct links to files or directories to the index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
</IfModule>
<IfModule !mod_rewrite.c>
# Tell PHP that the mod_rewrite module is DISABLED.
SetEnv HTTP_MOD_REWRITE Off
</IfModule>
Tambien he probado con especificando el dominio, pero tampoco funciona bien...
Y este es el dns record:
Citar
Name TTL Class Type Record
dominio.tk. 14400 IN A 000.000.000.000
localhost.dominio.tk. 14400 IN A 127.0.0.1
mail.dominio.tk. 14400 IN CNAME dominio.tk
www.dominio.tk. 14400 IN CNAME dominio.tk
ftp.dominio.tk. 14400 IN CNAME dominio.tk
cpanel.dominio.tk. 14400 IN A 000.000.000.000
whm.dominio.tk. 14400 IN A 000.000.000.000
webmail.dominio.tk. 14400 IN A 000.000.000.000
webdisk.dominio.tk. 14400 IN A 000.000.000.000
sub.dominio.tk. 14400 IN A 000.000.000.000
www.sub.dominio.tk. 14400 IN A 000.000.000.000
¿Sabeis donde puede estar el problema?
Gracias
saludos
gAb1
El problema esta en el rewrite cond.
RewriteCond %{HTTP_HOST} !^www\.
Esta condicion se aplica a cualquier direccion que no tenga www por delante. Lo que le tendrias que decir es que lo aplique solo a direciones que no tienen www ni ningun subdominio por delante.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^misitio\.com$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
SetEnv HTTP_MOD_REWRITE On
</IfModule>
Saludos
Muchas gracias ahora funciona correctamente. ::)