8 replies
I'm trying to put a php on my index.html page.
when I view the page I see the actual code.

Unsure what's going on I read a few things to see why. If I understood correctly I have two options.

one is to put something in the htaccess file to allow the php on the HTML page
or other option is to rename index.HTML to index.php and then just redirect index.HTML to index.php.
is this correct?
#indexhtml #php
  • Profile picture of the author Brandon Tanner
    All you have to do is give your index page a .php extension (rename it from index.html to index.php). Once you do that, there is nothing that you have to "redirect" (browsers know to look for index.html OR index.php, so you should only have a single index file).

    Alternately, if you already have a bunch of webpages that link to index.html and you don't feel like manually updating all of the links, then you can use htaccess to redirect index.html to index.php...

    Redirect 301 /index.html /index.php
    Signature

    {{ DiscussionBoard.errors[8191613].message }}
  • Profile picture of the author tedobee
    Thank you. Wanted to make sure that was correct before doing so.
    {{ DiscussionBoard.errors[8191646].message }}
  • Profile picture of the author RobinInTexas
    You could add one the following lines to your htaccess file:

    Code:
    AddType application/x-httpd-php .html .htm
    AddType application/x-httpd-php5 .html .htm
    Probably the second one will do the trick.
    Signature

    Robin



    ...Even if you're on the right track, you'll get run over if you just set there.
    {{ DiscussionBoard.errors[8191735].message }}
  • Profile picture of the author tedobee
    Changing the page name worked.

    Is it possibly to give me a basic example of a htaccess file? One to redirect the index.html to index.php and also one with robins example.

    I dont have one(htaccess file) so made one using what I found. I must have missed something as I ended up with just a white page.
    {{ DiscussionBoard.errors[8193038].message }}
  • Profile picture of the author RobinInTexas
    A single line, using one of my examples should work if you are using one of the popular unix hosts. If not, the best solution would be to use your hosting support.
    Signature

    Robin



    ...Even if you're on the right track, you'll get run over if you just set there.
    {{ DiscussionBoard.errors[8193591].message }}
  • Profile picture of the author tedobee
    Thanks again. Everything I need to do is is working great.
    I ended up changing the page name to php and just used this in the htaccess:

    index.html http://subdomain.mydomain.com/index.php

    it only worked though if I used the full url for whatever reason.

    So if I type in my browser http://subdomain.mydomain.com/index.html, I get taken to the renamed php page(great).
    But if I add www before the url like this: http://www.subdomain.mydomain.com/index.html

    , i get some DNS page rather than being redirected.

    Did I miss something or have to add something else or just contact my host?
    {{ DiscussionBoard.errors[8193755].message }}
    • Profile picture of the author RobinInTexas
      Add this at the beginning of your htaccess file

      Code:
      RewriteEngine on
      RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
      RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
      Signature

      Robin



      ...Even if you're on the right track, you'll get run over if you just set there.
      {{ DiscussionBoard.errors[8193839].message }}
      • Profile picture of the author tedobee
        Originally Posted by RobinInTexas View Post

        Add this at the beginning of your htaccess file

        Code:
        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
        RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
        Thanks for helping me here,

        It does the same thing though.
        {{ DiscussionBoard.errors[8193975].message }}

Trending Topics