htaccess de www a no www

i'm having a problem.

I have a Python(Django) website, and i want to delete the "www" from the url, so i have this htaccess:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.mydomain.com/$ [NC]
RewriteRule ^(/)?(.*) http://mydomain.com/$1 [R=301,L] 

It works, but the problem is if i enter an url like "www.domain.com/admin" or "www.domain.com/something" it redirects to "domain.com" instead of "domain.com/admin" or "domain.com/something".

Do you know what is wrong with my htaccess?

Muchas gracias por su tiempo y ayuda.

preguntado el 30 de junio de 12 a las 19:06

1 Respuestas

Cambiar ^(/)?(.*) a ^/?(.*). You're capturing that / and appending it onto your url, instead of the part you actually want to append with $1.

Respondido el 30 de junio de 12 a las 19:06

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.