2

Is there a way, without setting up a web server, to make Firefox or Chrome treat a locally stored site's root as it would be if viewed on the web?

So that when an HTML file is opened that contains URLs beginning with /

<link rel="stylesheet" href="/css/style.css">

instead of the browser searching for

file:///Users/me/Documents/Websites/Site/httpdocs/css/style.css

...and finding nothing, it would instead look for the file relative to httpdocs (because the browser was instructed to), and therefor find style.css?

When building a site that has root path URLs it's annoying that I can't view the pages in my browser without copying the whole site to the computer's root folder. All CSS, images, and scripts are not found because they are being searched for in my local machine's root. The URLs should remain as root paths however, because that will be "correct" once the site goes online.

Setting up a web server just for this purpose, on projects where I don't need it for anything else (when PHP and the like are not needed), is inconvenient.

Is there perhaps a setting or add-on that can be used to make a browser treat a specific site root folder stored locally as if it were hosted on the web? Thanks.

Mentalist
  • 1,530
  • 1
  • 18
  • 32
  • Browsers can't do that. There are real simple web servers that don't need much setup. An extension can change the absolute URLs in such a local file if you allow it to run on file URLs. – wOxxOm Jan 25 '19 at 05:11
  • @wOxxOm "An extension can change the absolute URLs in such a local file if you allow it to run on file URLs." Yes, that sounds like exactly what I'm looking for. Are there any such extensions you can name? I've been searching but have found nothing so far. – Mentalist Jan 25 '19 at 05:22

0 Answers0