# Viewing a webpage using localhost

**URL:** https://boards.straightdope.com/t/viewing-a-webpage-using-localhost/629374
**Category:** Factual Questions
**Created:** [July 25, 2012, 7:46pm UTC](https://boards.straightdope.com/t/viewing-a-webpage-using-localhost/629374 "2012-07-25T19:46:16Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Saint\_Cad](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/saint_cad/32/18907_2.png) [@Saint\_Cad](https://boards.straightdope.com/u/Saint_Cad)
#### Post date: [July 25, 2012, 7:46pm UTC](https://boards.straightdope.com/t/viewing-a-webpage-using-localhost/629374/1 "2012-07-25T19:46:16Z")

</div>

I want to test out some PHP code I wrote and run a small website through IIS7 just to test it before it gets uploaded to the host. Either my problem is unusual or my Google-fu is weak but here is the problem.

IIS7 - Seems to be working fine. I get the “Welcome” splash page  
PHP - Installed and ready to go  
But when I try to call up any webpage through local host I get “Internet Explorer cannot disply the webpage.”  
I’ve tried a file in the default directory: [http://localhost/menu.html](http://localhost/menu.html)  
I’ve tried a file in another directory: [http://localhost/C:/saintcad/test.html](http://localhost/C:/saintcad/test.html)  
I’ve tried setting up a virtual domain: [http://localhost/www.HiThere.com/test.html](http://localhost/www.HiThere.com/test.html)

All give the same “Cannot display” error. What am I missing?

---

<div class="post-metadata">

### Author: ![Kinthalis](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/kinthalis/32/16084_2.png) [@Kinthalis](https://boards.straightdope.com/u/Kinthalis)
#### Post date: [July 25, 2012, 7:49pm UTC](https://boards.straightdope.com/t/viewing-a-webpage-using-localhost/629374/2 "2012-07-25T19:49:42Z")

</div>

In IIS, did you set the site to point to the directory where your index.html/php/asp is located?

---

<div class="post-metadata">

### Author: ![Saint\_Cad](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/saint_cad/32/18907_2.png) [@Saint\_Cad](https://boards.straightdope.com/u/Saint_Cad)
#### Post date: [July 25, 2012, 7:52pm UTC](https://boards.straightdope.com/t/viewing-a-webpage-using-localhost/629374/3 "2012-07-25T19:52:44Z")

</div>

NVMD  
Fuck!!! The publishing service wasn’t started even though its on automatic. Working now except it doesn’t want to go to a folder thats not in the default folder but I can figure that out.

---

<div class="post-metadata">

### Author: ![chrisk](https://avatars.discourse-cdn.com/v4/letter/c/6de8d8/32.png) [@chrisk](https://boards.straightdope.com/u/chrisk)
#### Post date: [July 25, 2012, 7:54pm UTC](https://boards.straightdope.com/t/viewing-a-webpage-using-localhost/629374/4 "2012-07-25T19:54:44Z")

</div>

First thing I’d suggest is going into your IE advanced settings and turning off the accursed ‘Show friendly HTTP Error messages’ option. (They’re no friend of mine!)

Then you might get to see the error message that IIS7 is actually sending.

The first URL looks fine to me - I’m not sure what you’ve done to set up your virtual domain, but I’d be very surprised if either of the other two links would work. Here’s what I’d generally test first other than the default directory, (in c:\inetpub\wwwroot)…

A subfolder of the default directory - if the local path is c:\inetpub\wwwroot\hithere est.html, then the URL for IIS7 would be [http://localhost/hithere/test.html](http://localhost/hithere/test.html)

Setting up a virtual directory - if you set up c:\saintcad\ as the saintcad virtual directory, then you could reach it with [http://localhose/saintcad/test.html](http://localhose/saintcad/test.html)

Good luck and let us know if you have more questions or updates!

On preview… well, it looks like you’ve got an update, but I think most of the advice above is still good. 🙂

---

<div class="post-metadata">

### Author: ![Saint\_Cad](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/saint_cad/32/18907_2.png) [@Saint\_Cad](https://boards.straightdope.com/u/Saint_Cad)
#### Post date: [July 25, 2012, 8:04pm UTC](https://boards.straightdope.com/t/viewing-a-webpage-using-localhost/629374/5 "2012-07-25T20:04:48Z")

</div>

Wait I spoke too soon.  
Grrrrrr!!!  
Localhost finds the webpage but the php code is not working. Basic \<?php echo “Hello world”; ?\> but it is not displaying in my webpage.

---

<div class="post-metadata">

### Author: ![chrisk](https://avatars.discourse-cdn.com/v4/letter/c/6de8d8/32.png) [@chrisk](https://boards.straightdope.com/u/chrisk)
#### Post date: [July 25, 2012, 8:36pm UTC](https://boards.straightdope.com/t/viewing-a-webpage-using-localhost/629374/6 "2012-07-25T20:36:35Z")

</div>

Did you check to make sure that PHP was properly registered as a CGI handler or ISAPI application handler in IIS7?

That might be handled by the PHP installer, but I think it requires some tweaking. It’s been a long time since I’ve worked with PHP tho…

---

<div class="post-metadata">

### Author: ![drbhoneydew](https://avatars.discourse-cdn.com/v4/letter/d/d78d45/32.png) [@drbhoneydew](https://boards.straightdope.com/u/drbhoneydew)
#### Post date: [July 25, 2012, 8:50pm UTC](https://boards.straightdope.com/t/viewing-a-webpage-using-localhost/629374/7 "2012-07-25T20:50:31Z")

</div>

> [@chrisk](#):
>
> Did you check to make sure that PHP was properly registered as a CGI handler or ISAPI application handler in IIS7?

Have a look in the IIS logs - if you’re getting 404.1 as the response code, then it isn’t enabled and allowed on that web application.

> [@chrisk](#):
>
> That might be handled by the PHP installer, but I think it requires some tweaking. It’s been a long time since I’ve worked with PHP tho…

If memory serves, the handler is registered, but not necessarily set to allowed on websites other than the default. I always seem to forget where stuff is in IIS7 ☹

---

<div class="post-metadata">

### Author: ![Saint\_Cad](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/saint_cad/32/18907_2.png) [@Saint\_Cad](https://boards.straightdope.com/u/Saint_Cad)
#### Post date: [July 26, 2012, 1:53am UTC](https://boards.straightdope.com/t/viewing-a-webpage-using-localhost/629374/8 "2012-07-26T01:53:15Z")

</div>

My PHP was working but I apparently missed a fundamental idea in web programming. A php script can be imported (included?) into another php file but not straight into a HTML file. At least I cant find a way to do it without involving javascript which simply is not worth it.

---

<div class="post-metadata">

### Author: ![Caught\_Work](https://avatars.discourse-cdn.com/v4/letter/c/919ad9/32.png) [@Caught\_Work](https://boards.straightdope.com/u/Caught_Work)
#### Post date: [July 26, 2012, 2:41am UTC](https://boards.straightdope.com/t/viewing-a-webpage-using-localhost/629374/9 "2012-07-26T02:41:09Z")

</div>

You need to send html files through the PHP parser to solve that problem.

---

<div class="post-metadata">

### Author: ![Saint\_Cad](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/saint_cad/32/18907_2.png) [@Saint\_Cad](https://boards.straightdope.com/u/Saint_Cad)
#### Post date: [July 26, 2012, 3:37am UTC](https://boards.straightdope.com/t/viewing-a-webpage-using-localhost/629374/10 "2012-07-26T03:37:54Z")

</div>

Actually, rewriting everything as php was easier than I thought.

---

<div class="post-metadata">

### Author: ![chrisk](https://avatars.discourse-cdn.com/v4/letter/c/6de8d8/32.png) [@chrisk](https://boards.straightdope.com/u/chrisk)
#### Post date: [July 26, 2012, 3:16pm UTC](https://boards.straightdope.com/t/viewing-a-webpage-using-localhost/629374/11 "2012-07-26T15:16:00Z")

</div>

Glad everything worked out ok!

---

<div class="post-metadata">

### Author: ![Saint\_Cad](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/saint_cad/32/18907_2.png) [@Saint\_Cad](https://boards.straightdope.com/u/Saint_Cad)
#### Post date: [July 27, 2012, 4:30pm UTC](https://boards.straightdope.com/t/viewing-a-webpage-using-localhost/629374/12 "2012-07-27T16:30:35Z")

</div>

> [@chrisk](#):
>
> Glad everything worked out ok!

They got the approval of the illustrious girlfriend so this weekend she gets to fill in the content and they go live next Monday.
