www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: index.php vs index.html

  1. #1
    Join Date
    Aug 2011
    Location
    Saginaw Mi
    Posts
    22

    Question index.php vs index.html

    I Website had posted a thread in another for5um about an hour ago on this very same subject. And yet I am still confused.

    When cunstructing a Dynamic Website should one use index.php or index.html ? It was said that index.html is better for SEO reasons.

    So with that being said. I guess I'm confused on just how to use Php for a Dynamic Website using the .html extension. I know one uses a .htaccess file, but what else does one use, I mean how do you make an index.html work with Php?

    Thank you....

  2. #2
    Join Date
    Mar 2009
    Location
    Yorkshire
    Posts
    266
    Honestly i wouldnt worry too much about it. If you are creating a php page then it will be easier to stick with the .php file extension. This does tell malicious users that you are using php and it may be worse from an seo point of view (im not an seo expert but i seriously wouldnt count on it making too much of a difference) but the problems arent big enough to worry about.

  3. #3
    Join Date
    Jan 2009
    Posts
    3,346
    Quote Originally Posted by ryanlund View Post
    Honestly i wouldnt worry too much about it. If you are creating a php page then it will be easier to stick with the .php file extension. This does tell malicious users that you are using php and it may be worse from an seo point of view (im not an seo expert but i seriously wouldnt count on it making too much of a difference) but the problems arent big enough to worry about.
    Search engines could care less what extension your pages use. They only care about the content. It could be difficult to secure proper hosting that allows you to change the parsed extension to html and doing so could also cause greater undue strain on the server (especially in shared hosting environments). It is much easier (and the standard way to do things) to keep the extension as php.

  4. #4
    Join Date
    Aug 2011
    Location
    Saginaw Mi
    Posts
    22

    Thank you

    Thank you for your advice....

  5. #5
    Join Date
    Aug 2011
    Location
    Saginaw Mi
    Posts
    22
    Quote Originally Posted by criterion9 View Post
    Search engines could care less what extension your pages use. They only care about the content. It could be difficult to secure proper hosting that allows you to change the parsed extension to html and doing so could also cause greater undue strain on the server (especially in shared hosting environments). It is much easier (and the standard way to do things) to keep the extension as php.
    I was going to use an index.php with an .htaccess extension that would take index.php and make it www.mysite.com. What is your take on that?

  6. #6
    Join Date
    Mar 2009
    Location
    Yorkshire
    Posts
    266
    Quote Originally Posted by criterion9 View Post
    It could be difficult to secure proper hosting that allows you to change the parsed extension to html and doing so could also cause greater undue strain on the server (especially in shared hosting environments).
    I dont think this advice is 100% right.

    A) Any host that allows you to use .htaccess will allow you to parse html as php.

    B) The strain on the server is the same as simply processing a php page. If your shared hosting can do that then it will be able to process .html pages as php.

  7. #7
    Join Date
    Aug 2011
    Location
    Saginaw Mi
    Posts
    22
    Quote Originally Posted by ryanlund View Post
    I dont think this advice is 100% right.

    A) Any host that allows you to use .htaccess will allow you to parse html as php.

    B) The strain on the server is the same as simply processing a php page. If your shared hosting can do that then it will be able to process .html pages as php.
    Thank you Ryan.... You all are great teachers....

    Ryan, question for you. What is your take on me wanting to use the php extension but then using htaccess to rewrite the extension to mysite.com ?

  8. #8
    Join Date
    Aug 2011
    Location
    Hertfordshire, United Kingdom
    Posts
    1
    It really doesn't matter. I'd usally go with .html and rewrite the .php to .html

  9. #9
    Join Date
    Mar 2009
    Location
    Yorkshire
    Posts
    266
    Quote Originally Posted by mooapo View Post
    Thank you Ryan.... You all are great teachers....

    Ryan, question for you. What is your take on me wanting to use the php extension but then using htaccess to rewrite the extension to mysite.com ?
    Honestly, i'm not entirely sure what you mean by this (my brain isnt working too fast today haha). Can you explain a little more?

  10. #10
    Join Date
    Aug 2011
    Location
    Saginaw Mi
    Posts
    22
    Quote Originally Posted by ryanlund View Post
    Honestly, i'm not entirely sure what you mean by this (my brain isnt working too fast today haha). Can you explain a little more?
    It's my fault, I'm not wording it write. Lol.... I'm not to savvy with proper php syntax, Lol....

    I'll just paste this:Canonicalization

    The easiest htaccess trick is to make sure that your site doesn’t have any canonicalization issues on the homepage.

    A lot of websites suffer from poor search engine rankings by having a number of different versions of the homepage, for example:

    http://www.yoursite.com

    http://yoursite.com

    http://www.yoursite.com/index.html

    http://yoursite.com/index.html

    These pages are all seen as different urls, despite them having exactly the same content in most cases. Google has got better at deciding which version to use over the past 12 months but you can still run into problems.

    To solve this issue simply add the following to your htaccess file:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^yoursite.com
    RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
    RewriteRule ^index\.html$ http://www.yoursite.com/ [R=301,L]

    This will redirect all versions to http://www.yoursite.com
    Last edited by mooapo; 08-22-2011 at 09:18 AM.

  11. #11
    Join Date
    Jan 2009
    Posts
    3,346
    Quote Originally Posted by ryanlund View Post
    I dont think this advice is 100% right.

    A) Any host that allows you to use .htaccess will allow you to parse html as php.

    B) The strain on the server is the same as simply processing a php page. If your shared hosting can do that then it will be able to process .html pages as php.
    a) This may or may not be the case depending on the enabled .htaccess options at the server level

    b) True, except that each html page that is not php also requires parsing. In a hosting environment where you pay by the proccessing/memory utilization it may be unwise to have php parse all html files.

    As another option you could do as was suggested above and leave the files as php but use a rewrite rule if the html doesn't exist to point to a php file of the same name. Though I'm still wondering why you would want to have an html extension for parsed server-side content in the first place.

  12. #12
    Join Date
    Aug 2011
    Location
    Saginaw Mi
    Posts
    22
    Quote Originally Posted by criterion9 View Post
    a) This may or may not be the case depending on the enabled .htaccess options at the server level

    b) True, except that each html page that is not php also requires parsing. In a hosting environment where you pay by the proccessing/memory utilization it may be unwise to have php parse all html files.

    As another option you could do as was suggested above and leave the files as php but use a rewrite rule if the html doesn't exist to point to a php file of the same name. Though I'm still wondering why you would want to have an html extension for parsed server-side content in the first place.
    Because I heard html is better for SEO....

  13. #13
    Join Date
    Jan 2009
    Posts
    3,346
    Quote Originally Posted by mooapo View Post
    Because I heard html is better for SEO....
    The search engines don't care what the URL is as long as each URL is unique. This could be yoursite.com/somePage.php?contentID=asd or yoursite.com/page/asd. Having a .html extension will gain you nothing as far as SEO goes.

  14. #14
    Join Date
    Aug 2011
    Location
    Kolkata
    Posts
    2
    Yes i agree with that. SEO has nothing to to do with the file extension.

  15. #15
    Join Date
    Nov 2010
    Posts
    6
    you can include any page... i think
    ex:

    PHP Code:
          <?php include("header.html"); ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles