Reputation: 2055
I have a website that works fine when deployed on a remote development server. However, when I move it to my local machine, all the images paths' are now not pointed to the right directory.
Where as <img src="/images/breadicon.png" />
used to work, I now get a 404 file not found.
When I update that to <img src="./images/breadicon.png" />
, the image is found, but I don't want to have to revert back all my links when I re-deploy this site - and of course I don't want to have to work from the remote server.
The issue is, without the .
, the path is perceived as http://localhost/images/breadicon.png
instead of http://localhost/sitename/images/breadicon.php
What can I do to resolve all the links and have my links without ruining the code for redeployment?
Upvotes: 0
Views: 1040
Reputation: 913
Your best option is probably to set up a web host on your local machine.
For example, if your live/remote site was http://www.example.com/
, you could set up a local web host as http://example/
.
I'm assuming you're on Windows and using Apache. You'd need to edit your hosts file (using notepad, running as administrator, usually found here: C:\Windows\System32\drivers\etc) to contain:
127.0.0.1 example
Then create an Apache host config file, for example:
<VirtualHost *:80>
ServerName example
DocumentRoot C:/Path/To/Site/example
</VirtualHost>
Then restart Apache and go to http://example/
. Assuming you follow a standard convention for links etc, this should do the trick.
Upvotes: 1
Reputation: 31647
Configure your webserver such that the site can be accessed under http://localhost/
instead of http://localhost/sitename
.
If that name is already used for a different purpose, create a virtual host named e.g. sitename
in the webserver and edit your hosts file so that sitename
points to 127.0.0.1
.
Upvotes: 0