# Using subdomains for redirection only (Special for Django)

**URL:** https://forum.djangoproject.com/t/using-subdomains-for-redirection-only-special-for-django/11698
**Category:** Using Django
**Created:** [January 19, 2022, 11:31pm UTC](https://forum.djangoproject.com/t/using-subdomains-for-redirection-only-special-for-django/11698 "2022-01-19T23:31:07Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tragicomic](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/tragicomic/32/2285_2.png) [@tragicomic](https://forum.djangoproject.com/u/tragicomic)
#### Post date: [January 19, 2022, 11:31pm UTC](https://forum.djangoproject.com/t/using-subdomains-for-redirection-only-special-for-django/11698/1 "2022-01-19T23:31:08Z")

</div>

Suppose that my domain is [example.com](http://example.com)

I want to set subdomains such as [blog.example.com](http://blog.example.com), [contact.example.com](http://contact.example.com) …

**In my use case** :

- The subdomains will never have unique content.
- They will always redirected to determined URLs.

Assume that,

**→** Site objects were created for them. (using [The “sites” framework](https://docs.djangoproject.com/en/4.0/ref/contrib/sites/))

```
site_1 : example.com
site_2 : contact.example.com
site_3 : blog.example.com
...

```

**→** Then, Redirects are handling with [The Redirects app](https://docs.djangoproject.com/en/4.0/ref/contrib/redirects/).

**Example Redirects Goals:**

```
>>> redirect_1 = Redirect.objects.create(
... site_id=1,
... old_path='/contact-us/',
... new_path='/contact/',
... )

>>> redirect_2 = Redirect.objects.create(
... site_id=2,
... old_path='/',
... new_path='https://example.com/contact/',
... )

>>> redirect_3 = Redirect.objects.create(
... site_id=3,
... old_path='/first-blog/',
... new_path='https://example.com/blog/first-blog/',
... )

```

**My questions**

**-** Can [The sites framework](https://docs.djangoproject.com/en/4.0/ref/contrib/sites/) and [The redirects app](https://docs.djangoproject.com/en/4.0/ref/contrib/redirects/) be used this way with subdomains?

**-** If possible, how should subdomains be configured for this use case?

**Note:** Assume that there is no configuration related to subdomains in the project and that what is wanted to be done is prefer to done by Django side as much as possible.
