Hi All, I've had my wildlife site through a very restrictive host for the past year, so much so that the onyl things you can control are html, a bit of css, and the only things you can add are javascripts. They do not support any form of php etc. Now I'm going to move my whole site over so I can start using php, blogs, xml, and so on, but what I wanted to know was if I should name all my pages www.mydomain/category.php instead of .html? Can I edit my pages using simple html code if I name all my pages .php? I want to add rss feeds etc to my site and I don't want to use java? and for other reasons. Cheers Dean
You can name all files .php .php files are returned to client as normal html files regardless of php code. The php code are prosessed on server. While the result are returned to client. I.e.: <html> <head> <title>My Site</title> </head> <body> Hello World! </body> </html> PHP: Will return a page displaying the text "Hello World!" and have the tile "My Site" The page: <html> <head> <title>My Site</title> </head> <body> <?php echo 'Hello World!'; ?> </body> </html> PHP: Return same result.
To use PHP it is better to use the file extensions .phtml or .php I went through a similar conversaion acouple of years agoa and I did not want to lose any of the search engine index links that had accumulated over the years prior to the change. Assuming that you are on an Apache system, you can solve the problem in a .htaccess file in the top level of the website. It contains the following lines: RewriteEngine on RewriteRule ^(.*)\.html$ $1 [C,E=WasHTML:yes] # rewrite to document.phtml if exists RewriteCond %{REQUEST_FILENAME}.phtml -f RewriteRule ^(.*)$ $1.phtml [S=1] # else reverse the previous basename cutout RewriteCond %{ENV:WasHTML} ^yes$ RewriteRule ^(.*)$ $1.html Code (markup): If you prefer to use the php extension instead of phtml change the phtml to php in the above.
The only difference between php and html file extensions is that anything in a php file you can use php code. You can use html markup in either. I'd either use mod_rewrite to change the php extensions to html or use .htaccess code so that you can run php code in a html file, doing this will preserve your indexed page ranking in SE's. You could 301 from the old to new url's also if your preferred. Lots of ways to go about it.
Thanks Guys, I'm actually going through a tough decision process http://forums.digitalpoint.com/showthread.php?t=165853 As there is a lot I want to do with my site but am not quite sure which way to go.
My advice is don't rename your files to .php because you will lose your search engine rankings and have to start all over. Yes you could use .htaccess and mod rewrite, but the I have found the easiest thing to do is to use .htaccess and tell it to process .html files as php. Add the following line to a .htaccess file in your public_html folder and all files that are .html will be processed as php and you can use what even php instructions you like. AddHandler application/x-httpd-php .html Have Fun!
Funny - I've actually already done this with my traders site, but becasue I'm doing so much I forgot. Cheers LGRComp