django inner redirects
Posted
by Zayatzz
on Stack Overflow
See other posts from Stack Overflow
or by Zayatzz
Published on 2010-06-09T11:25:36Z
Indexed on
2010/06/09
11:32 UTC
Read the original article
Hit count: 367
django
|mod-rewrite
Hello
I have one project that in my own development computer (uses mod_wsgi to serve the project) caused no problems. In live server (uses mod_fastcgi) it generates 500 though.
my url conf is like this:
# -*- coding: utf-8 -*-
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^', include('jalka.game.urls')),
)
and
# -*- coding: utf-8 -*-
from django.conf.urls.defaults import *
from django.contrib.auth import views as auth_views
urlpatterns = patterns('jalka.game.views',
url(r'^$',
view = 'front',
name = 'front',),
url(r'^ennusta/(?P<game_id>\d+)/$',
view = 'ennusta',
name = 'ennusta',),
url(r'^login/$',
auth_views.login,
{'template_name': 'game/login.html'},
name='auth_login'),
url(r'^logout/$',
auth_views.logout,
{'template_name': 'game/logout.html'},
name='auth_logout'),
url(r'^arvuta/$',
view = 'arvuta',
name = 'arvuta',),
)
and .htaccess is like that:
Options +FollowSymLinks
RewriteEngine on
RewriteOptions MaxRedirects=10
# RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} ^www\.domain\.com
RewriteRule (.*) http://domain.com/$1 [R=301,L]
AddHandler fastcgi-script .fcgi
RewriteCond %{HTTP_HOST} ^jalka\.domain\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*) cgi-bin/fifa2010.fcgi/$1 [QSA,L]
RewriteCond %{HTTP_HOST} ^subdomain\.otherdomain\.eu$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*) cgi-bin/django.fcgi/$1 [QSA,L]
Notice, that i have also other project set up with same .htaccess and that one is running just fine with more complex urls and views
fifa2010.fcgi:
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
import sys, os
DOMAIN = "domain.com"
APPNAME = "jalka"
PREFIX = "/www/apache/domains/www.%s" % (DOMAIN,)
# Add a custom Python path.
sys.path.insert(0, os.path.join(PREFIX, "htdocs/django/Django-1.2.1"))
sys.path.insert(0, os.path.join(PREFIX, "htdocs"))
sys.path.insert(0, os.path.join(PREFIX, "htdocs/jalka"))
# Switch to the directory of your project. (Optional.)
os.chdir(os.path.join(PREFIX, "htdocs", APPNAME))
# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "%s.settings" % (APPNAME,)
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
Alan
© Stack Overflow or respective owner