Urlpattern Regex is not working as expected

I have a Django website and for the times that pages are not ready I want to redirect any URL to a specific maintenance page.

So in the urlpatterns of my website I added this regex expecting it to capture anything after / but it's not working. urlpatterns = [ path(r'/.*',maintenance_view,name='maintenance') ]

I found the answer myself. The problem was that I had to use re_path and also in the regex django was not caring about the "/", so I removed it.

from django.urls import re_path    
re_path(r'.*',maintenance_view, name='maintenance')
Back to Top