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} ^$ [NC]
RewriteRule ^(/)?(.*)$1 [R=301,L] 

It works, but the problem is if i enter an url like "" or "" it redirects to "" instead of "" or "".

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.