Add static content to localhost

If I create a new web project in WebStorm and hit run I get a localhost:<port>/<project> URL.

Is there a way to add static content to the localhost server as it would be out on the live server?  I have a public directory that holds static content that is shared amongst all my sites.  I use relative paths so that way as my code moves through Integration, QA, to PROD it always works.

Any ideas?

Comment actions Permalink

Not sure I follow you... Do you mean changing built-in web server URL from 'localhost:63342/project_name' to just 'localhost:port'?
You can't change the doc root to have the pages accessible as

, but you can try changing hosts file to make them accessible as
, where <project_name> is a name set in hosts file, like ' <specified_name>', as it's written in
Comment actions Permalink

No, I am looking for a way to add a directory that has static content, to the server, so my project can access it.


Directory (external to the project)

And I have a project with a webpage that uses that main.css  /webstorm workspace/test/index.html, but reference it by relative path to the server

<link href="/public/css/main.css" rel="stylesheet">
I click run in Webstorm and http://localhost:63342/test/index.html comes up, obviously the server doesn't know about /public/css/main.css
Is there a way to configure the server to add that directory as part of the server?
I hope that makes sense.
Comment actions Permalink

Well ... you can always add any external folder as Additional Content Root (Settings | Project | Directories) so it will become part of the project ... but that will not help with URL as (as described above by Elena) the URL for such resource will still include project name in it (e.g. /test/public/css/main.css)

Although you may try marking that folder as a Resource Root -- may help (not so sure though)

Comment actions Permalink

Thanks.  I will give that a try.  That is what I was looking for to be able to add a directory.


Please sign in to leave a comment.