Reputation: 644
I'm working on Django 1.11, the URL,
http://djangoserver:8002/dj/dev/userlogin/789
works with development server, but with apache URL:
http://djangoserver/dj/dev/userlogin/789
it throws Page not found (404)
error.
Regex used for the URL is :
url(r'^[0-9]+$', views.userlogin.login , name='login'),
The reset of pages are displayed properly.
I have tried solution posted in the following posts which did not work for me: django application works on development server but I get 404 on Apache
working on django development server but not on apache
django production server: root path
I'm not using any virtualhost.My httpd.conf file code snippet:
WSGIScriptAlias /dj /var/www/html/dev/dev/wsgi.py
WSGIDaemonProcess djangoserver python-path=/var/www/html/dev
WSGIProcessGroup djangoserver
WSGIScriptAlias /dj /var/www/html/dev/dev/wsgi.py process-group=djangoserver
<Directory /var/www/html/dev/dev >
# Options -Indexes +SymLinksIfOwnerMatch
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static/ /var/www/html/dev/dev_app/static/
<Directory /var/www/html/dev/dev_app/static/ >
Require all granted
</Directory>
Upvotes: 0
Views: 431
Reputation: 644
The only change I made is to declare WSGIScriptAlias along with process-group in httpd.conf file, code snippet:
WSGIDaemonProcess djangoserver python-path=/var/www/html/dev
WSGIProcessGroup djangoserver
WSGIScriptAlias /dj /var/www/html/dev/dev/wsgi.py process-group=djangoserver
<Directory /var/www/html/dev/dev >
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static/ /var/www/html/dev/dev_app/static/
<Directory /var/www/html/dev/dev_app/static/ >
Require all granted
</Directory>
Upvotes: 0
Reputation: 20702
You're setting /dj
as the the alias for your Django application, that means your Django app receives the path /dev/userlogin/789
, not /dj/dev/userlogin/789
. On your dev server that's the path that works, so you should change your Apache configuration to:
WSGIScriptAlias / /var/www/html/dev/dev/wsgi.py
So that /dj
is still part of the path parsed by your application.
Upvotes: 2