Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Installing SilverStripe /

Getting SilverStripe up and running on your computer and on your web server.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Unable to load resources when using virtualhosts


Go to End


1192 Views

Avatar
jaminday

Community Member, 1 Post

4 January 2013 at 2:06am

Edited: 04/01/2013 2:07am

Hi all,
Just wondering if anyone has any advice on getting SilverStripe working with virtualhosts on a local WAMP server? I'm finding that the home page loads (on a vanilla install, v 3.0.3), but none of the resources are loading (e.g. CSS, JS). The browser appears to be looking for them at http://themes/simple/css/reset.css (for example), instead of http://silverstripe.dev/index.php/themes/simple/css/reset.css.

To clarify, I'm only having this issue when using a virtualhost. The resources load fine when running from http://localhost/silverstripe.

I suspect the problem is in my htaccess file, but I don't know enough about htaccess to work out how to fix it. Here's what I've got in my htaccess currently (which lives in the site's root directory):

#------------------------------------------------------------------------------
# Vhosts Server root folder. File .htaccess
# This file provides server security limiting access to the localhost only.
# Comment next four lines to deactivate. (Allows external access)
#------------------------------------------------------------------------------

Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1

#------------------------------------------------------------------------------
# To allow execution of cgi scripts in this directory uncomment next two lines.
#------------------------------------------------------------------------------

#AddHandler cgi-script .pl .cgi
#Options +ExecCGI +FollowSymLinks
Options +FollowSymLinks

#------------------------------------------------------------------------------
# Activate this section to use the Private Server Feature!
# AuthName:     Replace with a suitable name appropriate to your site
# AuthType:     Do not change
# AuthUserFile: ../../../htpasswd Corresponds to folder UniServer\htpasswd
#               In folder UniServer\htpasswd create a new folder e.g Vhost_1
#               In this new folder create a new file named .htpasswd
#               Edit this file and add a name and passwrd for example 
#               name123:password45
#               Path will look like this (replace xxx with your new folder):
#               ../../../htpasswd/Vhost_1/.htpasswd
# Note: AuthUserFile - File path is relative to server root
# To lock server, uncomment the next 4 lines. (A name and password is required)
#------------------------------------------------------------------------------

#AuthName "Uniform Server - Server Access"
#AuthType Basic
#AuthUserFile ../../../htpasswd/xxx/.htpasswd
#Require valid-user

### SILVERSTRIPE START ###
<Files *.ss>
	Order deny,allow
	Deny from all
	Allow from 127.0.0.1
</Files>

<Files web.config>
	Order deny,allow
	Deny from all
</Files>

ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html

<IfModule mod_alias.c>
	RedirectMatch 403 /silverstripe-cache(/|$)
</IfModule>

<IfModule mod_rewrite.c>
	SetEnv HTTP_MOD_REWRITE On
	RewriteEngine On
	RewriteBase '/'

	RewriteCond %{REQUEST_URI} ^(.*)$
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule .* framework/main.php?url=%1&%{QUERY_STRING} [L]
</IfModule>
### SILVERSTRIPE END ###

Any ideas?