0

Any idea how to browse file:///C:/Results/index.html from localhost using a href?

i created the test html file (C:/ser/xampp/htdocs/filter/file.html) and place the link to local page (C:/Results/index.html) and i tired to open that link from (http://localhost/filter/file.html) it didn't work. But when i tired to open link from (file:///C:/ser/xampp/htdocs/filter/file.html) it worked.

I hope this make sense.

I googled it but didn't find any useful solution. Any idea how to solve this?

3
  • Does the XAMPP maps localhost to your folder ? i.e. what is the DocumentRoot of the Apache ? Commented Jul 31, 2013 at 4:09
  • @ShivanRaptor its '/ser/xampp/htdocs' but it didn't work for file:///C:/ser/xampp/htdocs/filter/file.html also Commented Jul 31, 2013 at 4:12
  • C:\Windows\System32\drivers\etc\hosts .Just paste code:127.0.0.1 localhost 127.0.0.1 localhost.Then restart xampp. Commented Jul 31, 2013 at 4:30

1 Answer 1

1

If the path is given like as below and if you access from localhost, it will make a search for a file which is inside htdocs folder

<a href="file:///C:/Results/index.html">Click Here</a>

To access the C:/Results folder, create a VirtualHost for the C:/Results and give that respective ip to the href like below. So that you can access the file from localhost.

<a href="http://192.168.1.4:1003/index.html">Click Here</a>

To create VirtualHost, * Open /etc/apache2/httpd.conf and enter the below lines. Dont delete other lines

<VirtualHost 192.168.1.4:1003>
DocumentRoot "file:///C:/Results"
</VirtualHost>

* Open /etc/apache2/ports.conf and enter the below lines. Dont delete other lines

Listen 1003

* Restart apache.

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

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.