Search code examples
javascriptphphtmlapachehtdocs

Unable to open a file on local sever


While writing 'localhost' as url in the browser, the index.html at this location runs: **file:///C:/xampp/htdocs/PrepLift/html/index.php**

Generally, writing localhost as url in a browser, the index.html file saved at htdocs runs. But in my case index.html kept at other location runs.

If i want to run a index.html file kept in htdocs, what i should write as url?

let's suppose I want to run this file:///C:/xampp/htdocs/wp_blog/accesspress-lite/index.php on the browser using localhost. (This file is in some other branch folders saved in htdocs). What url should I write?

As the target file which I want to run is in the folder before the location of index.html running by localhost.


Solution

  • Run Server and open on http protocol ... file protocol will not execute php code

    You are using xampp. So run it and access it at something http://localhost/wp_blog/ ( if your port is not 80 than http://localhost:PORT_NO/wp_blog/ for example PORT_NO = 8000 than http://localhost:8000/wp_blog/

    You can also run default php server like this (if php is available globally): Go to public folder -> open cmd -> Type "php -S localhost:8000"