4

My CSS / JS is not loading when using an alias in the httpd.conf

The site loads with all static files when using the localhost

WSGIScriptAlias / "d:\www\python\skillshare\src\mvp_landing\wsgi.py"

result;

http://localhost/

The site loads but with no css and js when adding the alias

WSGIScriptAlias /picon "d:\www\python\skillshare\src\mvp_landing\wsgi.py"

result;

http://localhost/picon/

My Current Dir structure below;

D:\www\python\skillshare\src\mvp_landing\wsgi.py
D:\www\python\skillshare\src\manage.py

D:\www\python\skillshare\static\static\
D:\www\python\skillshare\static\media\
D:\www\python\skillshare\static\templates\

Below my current httpd.conf (apache2.2);

WSGIScriptAlias /picon "d:\www\python\skillshare\src\mvp_landing\wsgi.py"

<Directory "d:/www/python/skillshare/src/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order allow,deny
    Allow from all
</Directory>

My Settings.py below

STATIC_URL = '/static/'

    # Template location
    TEMPLATE_DIRS = (
        os.path.join(os.path.dirname(BASE_DIR), "static", "templates"),
    )

    if DEBUG:
        MEDIA_URL = '/media/'
        STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static", "static")
        MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static", "media")
        STATICFILES_DIRS = (
            os.path.join(os.path.dirname(BASE_DIR), "static", "static"),
        )

My urls.py below

urlpatterns = patterns('',
    url(r'^/$', 'signups.views.home', name='home'),

    url(r'^thank-you/$', 'signups.views.thankyou', name='thankyou'),
    url(r'^about-us/$', 'signups.views.aboutus', name='aboutus'),

    url(r'^customers/$', 'formlist.views.customers', name='customers'),
    url(r'^addcustomer/$', 'formlist.views.addcustomer', name='addcustomer'),

    url(r'^admin/', include(admin.site.urls)),
)

if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL,
                          document_root=settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL,
                          document_root=settings.MEDIA_ROOT)

Currently i am at a loss to which setting to adjust to get the static files working with the alias in place, any suggestion would be very much appreciated. Please let me know if additional setup information is required to answer the question.

Setup:

Windows server 2012 64bit
WAMP
Apache 2.2
Python 2.7
Django 1.6
Bootstrap (latest)

regards.

0

2 Answers 2

3

Did you add the Alias for static in your httpd.conf ? Something like:

Alias /static/ D:\www\python\skillshare\static\static

<Directory D:\www\python\skillshare\static\static>
    Options -Indexes FollowSymLinks
    Order deny,allow
    Allow from all
</Directory>
Sign up to request clarification or add additional context in comments.

Comments

1

Great, I had to remove the / to get it to work, but it worked!

Alias /static D:\www\python\skillshare\static\static

<Directory D:\www\python\skillshare\static\static>
    Options -Indexes FollowSymLinks
    Order deny,allow
    Allow from all
</Directory>

1 Comment

I edited my answer to remove the /. I'm happy to hear that you found the solution!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.