Hi One of my site is done in .html, most of the files. I need to insert some php into those files, but i'd like to keep the .html extension so as not to have to rename all my links etc. So basically, i want the server to go thru my html pages looking for php code. I was told to put the following code into my .htaccess : AddType application/x-httpd-php .html Code (markup): However it does not work, as when i load a page my browser wants to download a file. Something is wrong. Any idea on how to make it work? Is there anything to be done on the server side to enable this? Do i need to change other things in my html pages? Thanks for the help.
What file does your browser try to download? In the past I have had some problems like this which usually turn out to be related to incorrect permissions on files.
Some servers aren't set up to allow HTML files to process PHP, even if you instruct them as such in your .htaccess file. It's worth contacting your host to check this before you tear too much hair out trying to make it work.
In Dreamweaver, if you rename a file, it asks you if you want to update links in other files, this could be just what you need. Also, if you don't use Dreamweaver, you could get a free trial from Adobe's web site. I don't know if there are any other tools out there which do this.
it actually is the page html file, which is named something like 145gtht35 somehow! when i open it in notepad it turns out to be my page code source. oups and i don't have much to spare by the way! thanks guys for the help
you have to change the extension of the page to php if you want to use PHP in the script.php won't work in a HTML script if it is not saved as a PHP file.but you use html extension to access this php file by using mode_rewrite option.you just have to set the moderewrite engine on and add new rewriterules.there are so many tutorials available online for mod_rewrite works.just search google and get the result for mod_rewrite.
not true, it can be done with a htaccess if the server allows it, by telling the server to parse the html file looking for php. i know how to do that, thanks. however if all my internal links link to a .php extension, i'd rather then have a .php than a .html so if i rename my files in .php i will not mod_rewrite into .html i fear SEOwise if i change from .html to .php , as i have some good results with my .html pages. i'm number one in my field on a number of keywords and i'd like to be sure it'll remain so if my .html is changed in .php anyway, it appears my hoster won't let me use that AddType application/x-httpd-php .html Code (markup): it is on a shared server, must be the reason why
That addtype command will work on some shared hosts, apparently not yours. If you want to use php in what was once an html file while preserving links, mod_rewrite will do the trick. Just rename each file.html to file.html.php and then add the following rule to your .htaccess: RewriteEngine on RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*\.html)$ $1.php Code (markup): This rule will cotinue to serve a.html as normal, unless a.html.php exists, in which case that is served instead.