phpmysqlprocesswire

image and script link not good because of subfolder


I am new to ProcessWire and I have a simple question. I transferred from being hosted on a server to running form a local site and some images, scripts, and links to pages are not showing up correctly.

The Homepage can be found at "http://localhost/restaurant/release/" and, for example, a relative link to some script is currently something like <script src="/site/templates/scripts/f.js">.

The problem is that, when the browser tries to access this link, it actually gets "http://localhost/site/templates/scripts/f.js" instead of "http://localhost/restaurant/release/site/templates/scripts/f.js".

How does ProcessWire handle these kinds of links? And how do I fix them?


Solution

  • You need to set the base tag in your HTML head:

    <base href="http://localhost/restaurant/release">
    

    Use your links as per normal:

    <script src="/site/templates/scripts/f.js">
    

    Alternatively, simply omit the leading slash from the script src.