Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

index.php?


  • Please log in to reply
6 replies to this topic

#1 even821

even821

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 132 posts

Posted 05 September 2012 - 12:12 AM

does it matter if my index file is a php or html file? since i need to have a bit of php on my index page.
  • 0

#2 BenW

BenW

    CC Devotee

  • Community Manager
  • 976 posts
  • Programming Language:ActionScript
  • Learning:ActionScript

Posted 05 September 2012 - 02:52 AM

If you're running php from a page it generally needs to have a .php extension. You can use htaccess to run html pages as php, but I don't recommend this because its a needlessly complicated solution.

This would go in the htaccess file on your server:

<Files yourpage.html> AddType application/x-httpd-php .html </Files>

It tells the server to interpret yourpage.html as php.

The only time you should use this method is if you have an existing page that you're adding php to, and you don't want to break search engine rank for the page. Otherwise, use a php extension.
  • 0

fss_overall.png

 


#3 even821

even821

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 132 posts

Posted 05 September 2012 - 04:09 AM

you have misunderstood my question...
i am asking if the index file (the home file, the first file opened by the browser) needs to be a html file, or if i can have a .php file instead

but still appreciate the small lecture on htaccess, always love learning new stuff :)
  • 0

#4 Jmancuso

Jmancuso

    CC Regular

  • Member
  • PipPipPip
  • 45 posts

Posted 05 September 2012 - 06:38 AM

If you're running php from a page it generally needs to have a .php extension. You can use htaccess to run html pages as php, but I don't recommend this because its a needlessly complicated solution.


he answered your question here. For a shorter answer, if you are going to have php in any type of file, you have to use a .php extension or it will not execute the php code properly
  • 1

#5 BenW

BenW

    CC Devotee

  • Community Manager
  • 976 posts
  • Programming Language:ActionScript
  • Learning:ActionScript

Posted 05 September 2012 - 07:02 AM

Sorry about the misunderstanding :)

Using index.php is fine, as long as you don't also have an index.html file on the server. What happens is that whne a visitor reaches your site, the server checks through a list of possible homepage locations, and the first one that matches is what's shown to the user. Generally, index.html is higher priority than index.php, so it will be served first if it exists.

Does that answer your question better? :)
  • 1

fss_overall.png

 


#6 even821

even821

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 132 posts

Posted 05 September 2012 - 07:04 AM

Sorry about the misunderstanding :)

Using index.php is fine, as long as you don't also have an index.html file on the server. What happens is that whne a visitor reaches your site, the server checks through a list of possible homepage locations, and the first one that matches is what's shown to the user. Generally, index.html is higher priority than index.php, so it will be served first if it exists.

Does that answer your question better? :)


haha yes, thats the answer i was looking for.
thank you very much :D
  • 0

#7 BenW

BenW

    CC Devotee

  • Community Manager
  • 976 posts
  • Programming Language:ActionScript
  • Learning:ActionScript

Posted 05 September 2012 - 07:04 AM

You're very welcome :) glad I could help.
  • 0

fss_overall.png

 





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download