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 7949855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:05:41+00:00 2026-06-04T02:05:41+00:00

Every url works fine in both Apache and django runserver except for urls (pointing

  • 0

Every url works fine in both Apache and django runserver except for urls (pointing to views, not real files) like this:

foo.js

urls.py:

url(r'^foo.js$', 'myapp.views.foo', name="foo"),

views.py:

def foo(request):
    return HttpResponse("foo")

In development server calling this url outputs me foo

In Apache with mod_wsgi, with the same url i get 404

wsgi conf file (really basic):

import os
import sys, logging

sys.stdout = sys.stderr

path = '/var/www/vhosts'
if path not in sys.path:
   sys.path.insert(0, path)
   sys.path.insert(0, path + '/myapp')

os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Classic urls like /foo/ work as expected.

Where is the problem? Is it an apache behaviour that i don’t know / recognize? Is it Django routing?

edit:

After adding apache conf (thanks for the maybe obvious hint), i think that those AliasMatch on *.js are the problem.. i completely forgot them!

<VirtualHost *:80>
        DocumentRoot "/var/www/vhosts/myapp"
        ServerName www.myapp.local


    Alias /robots.txt  /var/www/vhosts/myapp/public/static/robots.txt
    Alias /favicon.ico /var/www/vhosts/myapp/public/static/favicon.ico

    AliasMatch ^/([^/]*\.css) /var/www/vhosts/myapp/public/static/$1
    AliasMatch ^/([^/]*\.js)  /var/www/vhosts/myapp/public/static/$1


    Alias /media/  /var/www/vhosts/myapp/public/media/
    Alias /static/ /var/www/vhosts/myapp/public/static/

    <Directory /var/www/vhosts/myapp>
                Order allow,deny
                Allow from all
        </Directory>

        WSGIDaemonProcess myapp.djangoserver processes=2 threads=15 display-name=%{GROUP}
        WSGIProcessGroup myapp.djangoserver

        WSGIScriptAlias / /var/www/vhosts/myapp/apache/django.wsgi
LogLevel info
</VirtualHost>
  • 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-04T02:05:43+00:00Added an answer on June 4, 2026 at 2:05 am

    Did you set up Apache to serve the directories set as MEDIA_ROOT and STATIC_ROOT at MEDIA_URL and STATIC_URL, respectively? In development, Django serves the static media for you so you don’t need a full webserver stack, but in production, it’s up to you to serve the files.

    UPDATE

    Just remove the AliasMatch lines. They’re unnecessary if you’ve already set up Alias directives for both /media/ and /static/. All static resources will be in one of those two directories.

    Also, don’t forget to run python manage.py collectstatic. Otherwise, the directory specified as STATIC_ROOT will be empty, which would obviously also result in 404s.

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

Sidebar

Related Questions

I have create Map view in my application, every thing works fine except the
Provide an example for the pseudo-regex: Match every url except those from example.com and
I found difficulty to load image from url in every 30 seconds in android
My problem is that every time I do some operation with an URL like
Every now and again, I need to start the Django development server, and have
I have Webview application that uses progress bar dialog. It works fine but the
i wrote a gps-application for the iphone and it all works fine but now
I've implemented the JQuery Async Treeview (in APS.NET MVC2) and it works fine, but
I have a completed app running in a QA environment. Everything works fine under
Not sure where I might have went wrong the code seems fine to me,

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.