Redirects from subdomain urls

I’m using The redirects app.

Suppose that my domain name is

As in the document, I can redirect to

However, I couldn’t figure out how to identify urls as “redirect from” written with subdomains.

I would like to redirect to

What should be the right approach for this?

Also must “” be a valid subdomain just for such a redirect?

Thanks in advance.

I could very well be wrong on this, but a cursory inspection of the RedirectFallbackMiddleware class gives me the impression that it supports a “cross-site” redirect. In other words, the new_path field could contain a value like (Should be rather easy to test…)

Depends upon what you mean by “valid”. In this case, “valid” simply means that something resolves the name to your IP address handling those requests, and so allows your browser to issue an HTTP request to that name - or that there is a proxy or some other traffic-management device that will translate requests to a different name to that name. (Django needs to receive that request as being sent to, however that happens.)

Yes, the new_path field can have such value.
The part that is not clear to me is related to old_path.

In the The “sites” framework, there is a following information.

In the redirects framework, each redirect object is associated with a particular site. When Django searches for a redirect, it takes into account the current site.

Let’s say the current site is

Does that mean the url to be redirected can only start with, if I’m not wrong?
(But, the url to be redirected to new path for me is

In this case, it seems that a following redirection cannot be made.


I hope I was able to explain more clear where I was stuck and what I was aiming for.

If the request is to, then the current site is, and that’s what you would need to have configured in the sites framework (along with and any other sites you want managed by the sites framework).

If you’re looking to completely remove, then yes, you’ll need to look at a different way to manage this. You could possibly handle this at the web server layer (nginx or apache), or you could make your own version of the redirect middleware.

1 Like


With the perspective I got from here, I did some more research about it.

I clarified what I wanted to achive and for that what I wanted to ask.

I couldn’t decide whether I should open a new topic for this purpose or post as a new message in this topic.

If that’s a question you’re asking, that’s really pretty much up to you. It’s a judgement call, probably depending upon how close your new / clarified question is to what you’ve already posted. If you’re just refining what’s here, then my suggestion would be to add to this thread. But if you’re going in a different direction with what you’re looking for, then I would probably suggest a new thread.

1 Like

In that case, since the main idea of the question and the details have changed in different direction, I created a new topic.

Accessible from;
Using subdomains for redirection only (Special for Django)

1 Like