-1

i have a website that's mostly written in html, but i have to load it into a server that require the first page to be a index.php. How can i do that?

I have my index.html. is there a way to create a index.php that just load the index.html?

i tried

 <html>
  <head></head>
  <body>
   <?php include 'index.html'; ?>  
  </body>
 </html>

but won't work.

i heard of get_file or to import header, but i'm clueless, i never used php. how should i do?

2 Answers2

0

You can just rename the file to index.php. It doesn't require that any actual PHP code be in the file, the server's PHP engine will still process the file (pretty quickly too, since there's no server-side code to interpret) and show the HTML.

David
  • 208,112
  • 36
  • 198
  • 279
  • @user3332267: That's a separate issue entirely. Loading the CSS doesn't happen on the server. When you open the page in your browser, your browser makes separate requests for the CSS file(s) (and any other page resources). What is the status of those requests? Use something like Firebug or Chrome tools to debug the page. – David Feb 20 '14 at 10:58
  • the cascade would be load PHP > load HTML > load CSS, so check your [paths](http://stackoverflow.com/questions/5815452/how-to-use-relative-absolute-paths-in-css-urls) in the HTML and make sure they relate to the CSS files – pulsar Feb 20 '14 at 11:03
  • sorry i didn't get what you mean. in my html code i have the regular code to read the css file... shouldn't just work fine if i only change the extension of the file from html to php? when i load it as html it works just fine – user3332267 Feb 20 '14 at 11:04
  • @user3332267: Yes, it should work as a `.php` file as well. How are you debugging this? You need to determine what's actually happening when the browser tries to load the `.css` file, "it doesn't work" isn't a problem description. – David Feb 20 '14 at 11:41
  • I'm quite new to web develop, i'm just trying to read the code, i have no idea how to debug it to find what's going on. – user3332267 Feb 20 '14 at 11:44
  • @user3332267: Using something like Firebug in Firefox or Chrome's developer tools, you can examine the requests being made to the server when you load a page. One of those requests should be for the CSS file. There you can see the details of the request and the server's response. That'll tell you what's happening when the page tries to load the CSS file. Additionally with those tools, you can inspect any given page element at runtime and see which styles have been applied to it. – David Feb 20 '14 at 12:37
0

PHP

<?php
header( 'Location: http://www.redirect-location.com' );  
exit();
?>

HTML

<meta http-equiv="refresh" content="1;url=http://www.redirect-location.com">

.htaccess ReWrite

RewriteEngine on
RewriteRule index\.html index.php [NC,R]

or

DirectoryIndex index.php index.html

In order for this to work you need to allow overrides for indexes in the apache config

AllowOverride indexes
Sašo Krajnc
  • 133
  • 2
  • 3
  • 11