AndyHyl15
AndyHyl15

Reputation: 5

How to fix a PHP website on localhost that shows as a directory and not a website?

I installed Webmatrix 3 yesterday to create a PHP website. When I try to run the basic PHP page, I only see the directory of the project files but I want to see the web page directly.

I only have a simple page so far, but this is a major issue. When I run the project file I only get:

localhost - /

06/07/2015    14:24        <dir> App_Data
06/07/2015    14:24        <dir> bin
06/07/2015    16:39          187 PHPPage.php
06/07/2015    15:11          659 web.config

The only edits to webmatrix have been adding the PHP extension file.

Upvotes: 0

Views: 1667

Answers (3)

Mike
Mike

Reputation: 1938

In WebMatrix you can decide what you want your default page to be. If you open the site settings one of them is Manage Default Pages and has a list of about 7 different page names.

Manage Default Pages

You can add your own custom named page at the bottom, then you don't have to use the default.php file name to have it automatically run instead of giving you the directory listing.

Upvotes: 0

Whiteclaws
Whiteclaws

Reputation: 952

Have you tried creating an .htaccess file in your webroot directory and writing this in?

DirectoryIndex <index-webpage>

Replace <> by your starting webpage (it is index.php by default)

Another cool tip is to add this to your .htaccess file.

Options All -Indexes

Now it won't display your files as a web directory when you don't have any DirectoryIndex

Edit: In your case, it would be DirectoryIndex PHPPage.php

Upvotes: 2

mrahmat
mrahmat

Reputation: 617

Rename your PHPPage.php to index.php

Only index.php is run automatically instead of showing the dir structure

Upvotes: 2

Related Questions