Django url rewrite without redirect

I use django and have hundreds of subdomain URLs

abc.domain.com 

want to rewrite to

 domain.com/site/abc/ 

Is it possible with url-rewriting that the user will not see

 domain.com/site/abc/ 

in his browser but sees

 abc.domain.com 

This can be done on the apache side. But my question is: can we do this inside django?

Thanks in advance!

+4
source share
3 answers

I do not quite understand what you are asking the question, but maybe some solution with request.urlconf and the usual middleware is a solution? https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.urlconf

0
source

The Django site structure provides some tools for working with multiple domains, but they all assume that for each deployment you have a different SITE_ID.

That said. You can probably write middleware that checks request.META['HTTP_HOST'] and then passes this information in your opinion in any way.

At this point, you can simply follow the Django docs when using the user site manager for your models.

0
source

Did you run apache, I think this request can be processed through the APACHE rewrite engine

0
source

All Articles