# Redirecting to new app for some URLs

**URL:** <https://forum.djangoproject.com/t/redirecting-to-new-app-for-some-urls/39237>\
**Category:** Getting Started\
**Created:** [March 1, 2025, 7:21am UTC](https://forum.djangoproject.com/t/redirecting-to-new-app-for-some-urls/39237 "2025-03-01T07:21:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![janedenone](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/janedenone/32/12025_2.png) [@janedenone](https://forum.djangoproject.com/u/janedenone)\
**Post date:** [March 1, 2025, 7:21am UTC](https://forum.djangoproject.com/t/redirecting-to-new-app-for-some-urls/39237/1 "2025-03-01T07:21:02Z")

</div>

My website’s main app contains around 12,000 pages, and I want to break out a small portion (~ 1%) into a new app with different URLs but keep the original URLs as redirects. The dispatcher config looks something like this:

```auto
# newapp.urls.py
path('newapp/<slug:page_url>', views.generic_newapp, name='generic_newapp')

# mainapp.urls.py
path('<slug:page_url>', views.generic, name='generic')

```

If I modify the main app’s generic view to execute `redirect('generic_newapp', page_url=page_url)` every time a page (`page_url`) is not found in the main app, the users will receive a correct 200 or 404 response in the end, but at the expense of them being sent to `newapp/some_non_existing_url_name` for every URL that does not exist in either app.

Is there a better way to handle the migration of 120 pages to a different app transparently without affecting the majority of pages/URLs?

---

<div class="post-metadata">

**Author:** ![janedenone](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/janedenone/32/12025_2.png) [@janedenone](https://forum.djangoproject.com/u/janedenone)\
**Post date:** [March 1, 2025, 8:11am UTC](https://forum.djangoproject.com/t/redirecting-to-new-app-for-some-urls/39237/2 "2025-03-01T08:11:52Z")

</div>

Found a solution:

```auto
# mainapp.views.py
try:
	requested_page = Page.objects.get(url_name=page_url)
except Page.DoesNotExist:
	requested_item = get_object_or_404(Item, url_name=page_url)
	return redirect('item', url_name=page_url)
return page_view(request, requested_page)

```
