1

I have ran into a problem where by using /js/filename.js or /images/image.jpg etc is not loading anything on my WAMP Server. What it seems like is that its not getting the base url properly here. Screenshots will give you better idea.

loading the files

Display

Trying to reference the files with "/" in the start but it fails to load anything. I need to have it because i would be working with URL Rewrites so in that case it should load the files from there. Please let me know about any wamp server setting that is causing this issue.

Regards.

1
  • Just a minor addition, whether or not i add the slash in the start, the files work perfectly fine on the site hosted on godaddy.I need to know the setting with which I can have the same environment created on WAMP Server. Commented Oct 28, 2020 at 5:53

2 Answers 2

1

You are referring to your files with a root-path like "/my-file.txt" (i.e. having a slash at begin), which would result to "C:/wamp/www/my-file.txt" being requested.

Change all your paths to be relative paths, for example to "./my-file.txt" path (i.e. with both dot and slash ./),

That would change the file request to something like "C:/wamp/www/my-project/public/my-file.txt" (if your HTML file is in public directory that is).

Sign up to request clarification or add additional context in comments.

Comments

0

Actually I would not recommend you using relative paths like ./myfile.txt or something else, as it can get somewhat messy when you try MVC in your code.

Instead I would recommend you set up a virtual host on your wamp machne.

Here you can read more about setting up virtual host in wamp https://john-dugan.com/wamp-vhost-setup/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.