title: Django - remove www from URLs
body: <p>I've added this to my <code>.htacces</code>:</p>
  
  <pre><code>RewriteEngine on
  RewriteCond %{HTTP_HOST} ^www\.
  RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
  </code></pre>
  
  <p>but then trying to reach <code>www.example.com</code> redirects me to:</p>
  
  <p><code>http://example.com/example/wsgi.py/</code></p>
  
  <p>because i have <code>WSGIScriptAlias / home/www/example.com/example/wsgi.py</code> directive in my <code>httpd.conf</code> and of course i get 404 error. </p>
  
  <p>Eventually, i've managed to <em>fix</em> this by adding next line in my <code>urls.py</code>:</p>
  
  <p><code>url(r'^example/wsgi.py/$', index),</code> (so it redirects to home page)</p>
  
  <p>but i'm not quite sure that this is the right way to do it (because when i try to reach <code>example.com</code> i see that web browser changes address quickly to <code>www.example.com</code> and then again to <code>example.com</code>)</p>
  
  <p>If anyone would ask, yes i've seen <a href="http://dryan.me/articles/remove-www-urls-django/" rel="nofollow">this</a> but this didn't help me either, because browser gets url recursive problem (example.com/example.com/example.com/example.com/example.com...)</p>
  
  <p><strong>EDIT : FOLDER STRUCTURE</strong></p>
  
  <p>This is my folder structure:</p>
  
  <p><code>\mysite\ 
          static\
          media\
          .htaccess
          manage.py
          mysite\
                   templates
                   templatetags
                   tinymce
                   static
                   urls.py
                   settigs.py
                   views.py
                   wsgi.py
                   models.py
                   forms.py
                   __init__.py</code></p>