Apache | Django: How to run websites on the back of the base URL?

I have a base url. http://baseurl.com/ I'm trying to run projects on the back. For example, http://baseurl.com/mongoose/ Projects are being executed, but the URL does not work properly, because they all refer to the base url. So for the About Me page, this points to http://baseurl.com/about instead of http://baseurl.com/mongoose/about

Is this something I need to change in django or apache? Am I what I'm trying to do even the best?

Based on the background of IIS.net, I know that in IIS you can “Build and Apply” on a site that essentially does what I am trying to achieve now with Apache and Django.

thank

+3
source share
2 answers

You do not have to do anything. Apache is supposed to set a request header with a name SCRIPT_NAMEthat is your base URL, and all URL callbacks take this into account.

How do you create these urls in your templates?

Refresh

So your problem is getting Flatpages URLs. The problem is that the usual way to calculate URLs dynamically so that they are taken into account SCRIPT_NAMEusing a function reverse()or tag {% url %}does not work with Flatpages, because they are not sent via .py URLs, but through special middleware that runs on 404 .

urls.py flatpages. flatpagemiddleware settings.py, urls.py :

url(r'^(?P<url>.*)$', 'django.contrib.flatpages.views.flatpage', name='flatpage'), 

:

<a href="{% url flatpage page.url %}">

.

+1

urls.py (-), , . , /something, . / URL-, . , reverse django.core.urlresolvers

0

Source: https://habr.com/ru/post/1780364/


All Articles