Adding www middleware
parent
ea412105d0
commit
477cf2f1bb
|
@ -0,0 +1,14 @@
|
|||
import re
|
||||
|
||||
from django.conf import settings
|
||||
from django.core import urlresolvers
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
|
||||
|
||||
class WWWMiddleware(object):
|
||||
|
||||
def process_request(self, request):
|
||||
url = request.build_absolute_uri(request.get_full_path())
|
||||
if 'www.' in url:
|
||||
non_www_url = url.replace('www.', '')
|
||||
return HttpResponseRedirect(non_www_url)
|
|
@ -49,12 +49,12 @@ USE_L10N = True
|
|||
|
||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
||||
# Example: "/home/media/media.lawrence.com/media/"
|
||||
MEDIA_ROOT = ''
|
||||
MEDIA_ROOT = '/Users/Nick/Code/snipt/snipt/media/'
|
||||
|
||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
||||
# trailing slash.
|
||||
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
||||
MEDIA_URL = ''
|
||||
MEDIA_URL = '/media/'
|
||||
|
||||
# Absolute path to the directory static files should be collected to.
|
||||
# Don't put anything in this directory yourself; store your static files
|
||||
|
|
Loading…
Reference in New Issue