Browser won't recognize .php extension for index page

10 posts by 3 authors in: Forums > CMS Builder
Last Post: February 25, 2009   (RSS)

By edg1 - February 24, 2009

I am a beginner with CMS Builder. I completed my website using html pages with Dreamweaver before integrating CMS Builder. I've been learning the way CMS Builder works and integrating it into my existing pages.

My question is, can i leave my page extensions as html, or do i need to change the extentions to php?

Thanks in advance for any help!
Anna

Re: [amb29] Browser won't recognize .php extension for index page

By Kenny - February 24, 2009

Anna -

Without some elaborate work-arounds, it is best to make sure your extensions are .php if you can help it.

Kenny

Re: [sagentic] Browser won't recognize .php extension for index page

By edg1 - February 24, 2009

Thank you Kenny -

My next question is – if the php extension is necessary, how do i get a browser to default to index.php instead of index.html when the url is entered? No one will know to type in "index.php" at the end...

Thanks again,
Anna

Re: [amb29] Browser won't recognize .php extension for index page

By Kenny - February 24, 2009

Anna,

You will need to get rid of the index.html or rename it to something else.

index.php will replace your index.html

Most servers have default settings about the order in which a default file is presented. typical order is:

index.html
index.php
default.html
default.php
home.html
home.php

The browser looks for one of these files as the default page to present based on the servers preferences. If you don't have a index.html, it will start looking for index.php instead.

I hope that makes sense. Let me know if you have any more problems.

Kenny

Re: [sagentic] Browser won't recognize .php extension for index page

By edg1 - February 24, 2009

Thanks again, Kenny.

I actually do not have an index.html, only an index.php, and i was getting the following error message:

'Error 403 - Forbidden
You tried to access a document for which you don't have privileges.'

I googled a way to redirect a url and found that i can redirect '/index.html' to '/index.php' using Apache in a plain text document named ".htaccess" I did that and it worked - is this the best way to redirect a url?

Thanks,
Anna

Re: [amb29] Browser won't recognize .php extension for index page

By Kenny - February 24, 2009

That works, but I would highly recommend asking your web host to configure Apache to allow .php in the Directory Index.

Do other .php pages work properly?

Re: [sagentic] Browser won't recognize .php extension for index page

By edg1 - February 24, 2009

The php pages in my site work very well, as long as there is a link that points to each specific page's url. If i type in http://www.domain/index.php, that works as well. My only issue is with the default, because viewers are used to the home page coming up automatically when they type in or link to a domain (with no page specified).

Thanks for your time and your input. I will contact my hosting company to see if this can be fixed - to allow .php as the next in line for the default, after .html as you said.

Thanks so much!
Anna

Re: [amb29] Browser won't recognize .php extension for index page

By Dave - February 24, 2009

Hi Anna,

Asking your host is the best first step. But depending on your hosting setup, some let you change some of the settings yourself with .htaccess files. If your host allows this the following directives let you setup index.php as a default file (followed by index.html if there is no index.php):

DirectoryIndex index.php index.html

Next, it is also often possible to have your web server treat other files (such as .html) as php even if they don't have the extension. There's more info about that here: http://www.google.com/search?q=html+files+as+php

But to start, you're probably better off to stick with .php for php and .html for HTML and get the server configured properly to show index.php files by default.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [amb29] Browser won't recognize .php extension for index page

By Dave - February 25, 2009

Thanks for posting back. Glad to hear it's working! :)
Dave Edis - Senior Developer
interactivetools.com