title: Redirecting Django root to admin panel
body: <p>I'm trying to redirect the Django site root to the Django admin panel, and I've mostly got it up and running.  However, I've noticed that unless there's a trailing slash in the project URL, the links on the page don't include the project folder, and instead try to find the apps in the site root.</p>
  
  <p>So, say I've got a project <code>foo</code>, and an app <code>bar</code>. If you visit <code>http://server/foo/</code> (with a trailing slash), everything works fine, and the links on the page go to <code>http://server/foo/bar</code>. However, if one visits <code>http://server/foo</code>, the generated links go to <code>http://server/bar</code> instead, which generates a 404 error. </p>
  
  <p>If I set the <code>WSGIScriptAlias</code> to point to <code>/foo/</code> instead of <code>/foo</code>, it would give a 404 error if I navigated to <code>/foo</code>. I tried to force a trailing slash in the Apache conf with Redirect, but I end up generating a recursive redirect (<code>http://server/foo//////...</code>). I haven't yet tried using a .htaccess file, but I suspect the same thing might happen. </p>
  
  <p>I tried the same thing in <code>urls.py</code>, however:</p>
  
  <pre><code>url(r'^$', redirect_to, {'url': '/'}), # goes to server root http://server/
  url(r'^$', redirect_to, {'url': 'foo/'}), # goes to http://server/foo/foo
  url(r'^$', redirect_to, {'url': '/foo/'}), # infinite redirect
  </code></pre>
  
  <p>I also tried simply appending a slash to all the Django urls like so:</p>
  
  <pre><code>url(r'^(.*)/', include(admin.site.urls))
  </code></pre>
  
  <p>But it fails to match anything at all in the project root folder (although if you navigate to the app, that seems to work OK).</p>
  
  <p>I'm using Apache 2.2 with mod_wsgi, here is the configuration:</p>
  
  <pre><code>Alias /static "C:/DJANGO~1/apps/django/django/contrib"
  
  &lt;Directory 'C:/DJANGO~1/apps/django/django/contrib'&gt;
    Order allow,deny
    Allow from all
  &lt;/Directory&gt;
  
  WSGIScriptAlias /foo "C:/Djangostack/apps/django/scripts/django.wsgi"
  
  &lt;Directory 'C:/Djangostack/apps/django/scripts'&gt;
    Order allow,deny
    Allow from all
  &lt;/Directory&gt;
  </code></pre>
  
  <p>And this is the <code>urls.py</code> that mostly works:</p>
  
  <pre><code>urlpatterns = patterns('',
    url(r'^', include(admin.site.urls)),
  )
  </code></pre>
  
  <p>I've made sure <code>APPEND_SLASH</code> is set to True, but it doesn't seem to work in the root project folder.</p>