user3699792
user3699792

Reputation: 1

Open website in browser directly when http://localhost is input

I am using xampp and i have a website in htdocs.

The home page home.html is in a folder website -> website/home.html. I want to host that website in xampp, so my question is, how to access the home page home.html directly.

Is there any modification that need to be done?

Upvotes: 0

Views: 5875

Answers (3)

nikonan
nikonan

Reputation: 166

Although it might be preferable to change virtual hosts, a simpler solution would be to use an HTML Redirect. Create, in the htdocs folder, an index.html file with this line in it

<meta HTTP-EQUIV="Refresh" CONTENT="0; URL=http://localhost/website/home.html">

(assuming that localhost is reachable and the structure of the directory is htdocs/website/home.html)

Upvotes: 0

tobylaroni
tobylaroni

Reputation: 863

Are you saying that you want home.html to open as the default page when browsing to http://localhost? If so, you'll want to add home.html as a Directory Index file. In standard Apache HTTPD server configuration, you'd just look for a block looking like:

<IfModule dir_module>
  DirectoryIndex index.html index.php 
</IfModule>

Just add home.html to the end of the DirectoryIndex line, so you'd get:

<IfModule dir_module>
  DirectoryIndex index.html index.php home.html
</IfModule>

The location of your httpd.conf file, where you'll need to make this change, depends on your XAMPP installation.

If this is not your question, you'll need to provide more specifics.

Upvotes: 0

Rene Padillo
Rene Padillo

Reputation: 2358

You'll just have to move your home.html to the htdocs folder (just simple move it outside your website folder) and then make sure to rename it as index.html.

Since index.(php/html) would be automatically be opened once you access your localhost. But take note this will replace the XAMPP's default index page which is not a problem (unless you want to make use of it).

Upvotes: 1

Related Questions