Use the same Apache instance to run Django and media files

Source: Internet
Author: User
Django itself is not used to serve media files; You should leave this job to the Web server you choose. We recommend using a separate Web server (that is, one that does not run Django) to serve media. For more information, see the section below.

However, if you have no other choice, you can only serve media files on the same Django Apache VirtualHost, where you could turn off Mod_python for a specific part of the site:

 
 
  
    SetHandler None
 
 

Change location to the root directory where your media files are located.

You can also use to match regular expressions. For example, the following syntax defines Django to the root of the Web site, and explicitly masks the media subdirectory and any URLs that end with. jpg,. gif, or. png:

 
 
  
    SetHandler python-program  pythonhandler django.core.handlers.modpython  SetEnv django_settings_ MODULE mysite.settings
 
 
 
 
  
    SetHandler None
 
 
 
 
  
    SetHandler None
 
 

In all of these examples, you must set up DocumentRoot so that Apache can know where you store the bits of the static file

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.