I have an existing static website that is served via apache. I wanted to add dynamic features to that site so I created a Django app that lives in a subfolder (ie. /django-site/
). I have this configured like this:
WSGIDaemonProcess django_site processes=5 threads=5 user=user group=group python-home=path/to/virtualenv
WSGIScriptAlias /django-site /var/www/django_site/wsgi.py
<Location /django-site>
WSGIProcessGroup group
</Location>
But now I would like to replace certain pages that were originally static pages in the root directory. But I don't want to replace all of the static pages.
I know that Django recommends putting your static files in a subdirectory like /media
or /static
and Django configured to be the root directory but since I have a long legacy of these static pages being in the root directory and external links to these pages I don't want to change that.
Is there a recommended way to replace these static pages with a dynamic ones?
Here are a few ideas that I have thought of:
ProxyPass
to replace pages one at a timeYou could use Apache mod_rewrite to keep the existing links functional. The documentation suggests this:
Description: How can we transform a static page foo.html into a dynamic variant foo.cgi in a seamless way, ie without notice by the browser/user.
Solution: We just rewrite the URL to the CGI-script and force the handler to be cgi-script so that it is executed as a CGI program. This way a request to /~quux/foo.html internally leads to the invocation of /~quux/foo.cgi.
RewriteEngine on
RewriteBase "/~quux/"
RewriteRule "^foo\.html$" "foo.cgi" [H=cgi-script]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.