Images not showing after moving to LocalHost

我只是一个虾纸丫 提交于 2019-12-08 10:05:17

问题


I recently switched to developing on local host rather than on my desktop. My website works fine on the desktop but now when i run it on local host none of my images work.

<a class="navbar-brand" href="#"><img src="logo.png" alt="logo" /></a>

That is how I'm including my images.

My localhost url is:

http://michaels-macbook-pro.local

Im getting the following error in the console:

[Error] Failed to load resource: the server responded with a status of 403 (Forbidden) (logo.png, line 0)

回答1:


It seems to be a permissions issue.

View your file permissions in the command line with:

ls -l

You want your image files to have read access for all users. Change your permissions to something like 644 for the folder and 711 for the images:

chmod 644 images
chmod 711 images/logo.png

For info about permissions see http://www.computerhope.com/unix/uchmod.htm

You probably have the issue because you are not the 'owner' of the files on your localhost (you can also view the owner of a file using ls -l). So if your image files have permissions of say, 700, then only the 'owner' has read access. Whereas on your desktop you will be the owner of the files so you have read permission.



来源:https://stackoverflow.com/questions/37467363/images-not-showing-after-moving-to-localhost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!