Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7865041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:57:56+00:00 2026-06-02T23:57:56+00:00

In my Django urlconf, i’d like to return a 404 for requests probing for

  • 0

In my Django urlconf, i’d like to return a 404 for requests probing for scripts. Otherwise, the request is needlessly hitting the database to look for a corresponding FlatPage, since i’m using the FlatPage middleware.

My problem is that the following pattern, which matches correctly, is sending ‘php’, ‘cgi’, or ‘pl’ as the template_name argument to the page_not_found view function.

urlpatterns = patterns('',
    # don't even bother looking up a flatpage for these matches
    (r'\.(php|cgi|pl)$', 'django.views.defaults.page_not_found'), 
    ...
)

What is a way to do that regex “or” logic without sending the match as a parameter to the view?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:57:57+00:00Added an answer on June 2, 2026 at 11:57 pm

    Non-capturing groups are indicated with (?:...).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In browser I get: Request URL: http://xxxxxx:8000/person/test/ Using the URLconf defined in person.urls, Django
My URLconf contains this pattern: url(r'^accounts/logout/$','django.contrib.auth.views.logout', name=logout), And I've trying to reverse that in
Django code samples involving post data often shows code similar to this: if request.method
These is my django URLconf: urlpatterns = patterns('', ('^hello/$', hello), (r'^polls/$', 'mysite.polls.views.index'), (r'^polls/(?P<poll_id>\d+)/$', 'mysite.polls.views.detail'),
The tag in question: < a href={% url django.contrib.auth.views.login %}>Login< /a> URLConf: from django.contrib.auth
I am going through the Django sample application and come across the URLConf. I
I generally add a catch-all 404 regex to my Django websites as the last
I am installing byteflow-0.7 on python 2.6.5 with django 1.3 on windows7(64-bits). Database used
Django has excellent URLConf and URL reverse mapping/matching. I'm looking for a tip/trick to
In my Django project, I used to have a single URLConf, urls.py at the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.