Thursday, September 1, 2022

[SOLVED] Django urls.py catches all existing HTML projects' urls on WampServer

Issue

I had WampServer working perfectly with Aptana IDE using multiple folders for different html projects. Then I installed Django and added this to Apache's httpd.conf:

Alias /images/ "c:/wamp/www/daas/templates/images/"
<Directory "c:/wamp/www/daas/images>
Order allow,deny
Allow from all
</Directory>

WSGIScriptAlias / "c:/wamp/www/daas/apache/django.wsgi"

<Directory "c:/wamp/www/daas/apache">
Allow from all
</Directory>

<VirtualHost *:80>
    ServerName 127.0.0.1
    DocumentRoot c:/wamp/www/daas/
</VirtualHost>

and now the virtual hosts I had for html projects...

NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
    ServerName localhost
    DocumentRoot 'C:\wamp\www'
</VirtualHost>
<VirtualHost 127.0.0.1>
    ServerName projectA.local
    DocumentRoot 'C:\wamp\www\projectA'
</VirtualHost>

don't load correctly because Django's urls.py is catching all urls The current URL, projectA, didn't match any of these regular expressions, even the ones not inside the Django's projects.

How can I solve this? On Djano's side or on Apache's side? Here (How do i run Django and phpmyadmin on apache webserver on ubuntu) is a similar problem but the solution didn't worked for me. And luckily localhost/phpmyadmin works correctly but localhost/projectA doesn't.


Solution

It looks like WSGIScriptAlias / "c:/wamp/www/daas/apache/django.wsgi" in your httpd.conf catches all requests on apache.



Answered By - Jingo
Answer Checked By - David Marino (WPSolving Volunteer)