Convert PHP addresses to HTML

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Ive heard about some sort of script or program that converts a web
address with a php extension to that with a html. E.g. say if you had the user would be able to access this via
We're creating a new site in php and dont want to effect our search
engine rankings by getting rid of all our existing html pages.

Any information would be appreciated.



Re: Convert PHP addresses to HTML

IWT schrieb:
Quoted text here. Click to load it

edit your httpd.conf or set a .htaccess file with this contens

   AddType application/x-httpd-php php php4 php3 html htm

Then you are able to save your php files with the extension .html and
the parse will be activated at request.


Re: Convert PHP addresses to HTML

IWT wrote:
Quoted text here. Click to load it

You could use
1) symbolic links in the file system (unix command ln -s),
2) redirects in html header from html to php file,
3) apache rewrite engine (see manual on,
4) add .html extension as type for php parsing in httpd.conf;
and maybe other approaches as well.

E. Dronkert

Re: Convert PHP addresses to HTML

"IWT" wrote:

Quoted text here. Click to load it

Are you on an Apache server? If so, try putting this in your .htaccess file:

RewriteEngine on
RewriteRule ^(.*)\.html$ $1 [C,E=dothtml:true]
RewriteCond %.php -f
RewriteRule ^(.*)$ $1.php [S=1]
RewriteCond % ^true$
RewriteRule ^(.*)$ $1.html

If your server receives a request for "/path/to/foo.html", it will first
check to see if a file "/path/to/foo.php" exists. If so, it serves up the
PHP file, otherwise the HTML file gets sent out.

If you're not on an Apache server, then you might be stuck. Ask your hosting
company what your options are.

phil [dot] ronan @ virgin [dot] net

Re: Convert PHP addresses to HTML

You have two options, both involve messing around with your Apache

The first is to include a rewrite rule in the config that is something
like the following:
RewriteRule ^(.*)[.]html$ $1.php [L,QSA]
Which redirects all requests for foo.htm to foo.php

The second is to tell Apache to process .html files as PHP.  Find the
following line in your apache conf:
AddType application/x-httpd-php .php
And change it to:
AddType application/x-httpd-php .php .html

Note that this would mean all .html files are run through the PHP
engine, which will probably increase the load on your server.  You can
get fancier and restrict the rule by directory, if that helps.


Re: Convert PHP addresses to HTML

IWT wrote:

Quoted text here. Click to load it

Better still, redirect both of those URLs to:

which might be PHP now, but after a future site revision might become a
PDF file, or perhaps a JSP script.

Toby A Inkster BSc (Hons) ARCS
Contact Me  ~

Site Timeline