Ignorar la carpeta venv en Git
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,34 +0,0 @@
|
||||
from django.conf import settings
|
||||
from django.http import HttpResponsePermanentRedirect
|
||||
|
||||
class SSLRedirectMiddleware:
|
||||
"""
|
||||
Middleware para redirigir:
|
||||
1. HTTP a HTTPS.
|
||||
2. Dominio sin `www` a dominio con `www`.
|
||||
3. Añadir `/es/` si no está presente.
|
||||
"""
|
||||
def __init__(self, get_response):
|
||||
self.get_response = get_response
|
||||
|
||||
def __call__(self, request):
|
||||
host = request.get_host()
|
||||
is_https = request.is_secure() or settings.DEBUG # Para entornos locales en DEBUG
|
||||
|
||||
# Redirigir a HTTPS si no está seguro
|
||||
if not is_https:
|
||||
url = request.build_absolute_uri().replace("http://", "https://")
|
||||
return HttpResponsePermanentRedirect(url)
|
||||
|
||||
# Redirigir al dominio con `www`
|
||||
if not host.startswith("www."):
|
||||
new_host = f"www.{host}"
|
||||
url = request.build_absolute_uri().replace(host, new_host)
|
||||
return HttpResponsePermanentRedirect(url)
|
||||
|
||||
# Redirigir a `/es/` si no está incluido
|
||||
if not request.path.startswith('/es/'):
|
||||
url = f"https://{host}/es{request.get_full_path()}"
|
||||
return HttpResponsePermanentRedirect(url)
|
||||
|
||||
return self.get_response(request)
|
||||
+4
-3
@@ -23,7 +23,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
SECRET_KEY = 'django-insecure-os9f6#@x_5*sfv2g6vyj*31$964_s%7(%&x0+m)crrbj^=0wus'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
DEBUG = False
|
||||
|
||||
ALLOWED_HOSTS = ['novawow.com', 'www.novawow.com', '95.216.107.200']
|
||||
SECURE_SSL_REDIRECT = True
|
||||
@@ -105,12 +105,12 @@ MIDDLEWARE = [
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'novawow.middleware.SSLRedirectMiddleware',
|
||||
'home.middleware.MaintenanceMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'novawow.urls'
|
||||
|
||||
URL_PRINCIPAL = 'http://localhost:8009'
|
||||
URL_PRINCIPAL = 'http://novawow.com:8009'
|
||||
|
||||
# Nombre del servidor
|
||||
NOMBRE_SERVIDOR = "Nova WoW"
|
||||
@@ -233,6 +233,7 @@ USE_TZ = True
|
||||
# https://docs.djangoproject.com/en/5.1/howto/static-files/
|
||||
|
||||
STATIC_URL = 'static/'
|
||||
STATIC_ROOT = 'static/'
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
|
||||
|
||||
@@ -15,6 +15,3 @@ urlpatterns += i18n_patterns(
|
||||
path('ckeditor5/', include('django_ckeditor_5.urls')),
|
||||
)
|
||||
|
||||
# Redirigir HTTP a HTTPS globalmente (opcional)
|
||||
if settings.SECURE_SSL_REDIRECT:
|
||||
urlpatterns = [path('', lambda request: HttpResponsePermanentRedirect('https://www.novawow.com'))] + urlpatterns
|
||||
Reference in New Issue
Block a user