View unanswered posts | View active topics It is currently Sat Jun 24, 2017 10:42 pm



Reply to topic  [ 6 posts ] 
 using htaccess to allow html pages to be parsed as php - I cannot get it to work ! 
Author Message
Junior Member

Joined: Sun Nov 12, 2006 2:43 pm
Posts: 3
Post using htaccess to allow html pages to be parsed as php - I cannot get it to work !
Hello,

I am planning to rebuild my website with header.htm, foot.htm, menu.htm files etc and using php includes within my exisiting .html files. I have been informed that php can be parsed my html pages as php by adding a rule to the .htaccess file, and have found several codes to use, but so far have been unable to get any of them to work. They either result in a request to download and save pages rather than show in the browser, or they do nothing.

The codes I have tried are:

AddType application/x-httpd-php .htm .html
-- results in attempted download

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
- results in attempted download

AddType x-httpd-php .php .htm .html
AddHandler application/x-httpd-php .php .htm .html
-- prevents php being read in php file (e.g. http://www.tranquillizer.co.uk/supplement-whey-protein.php)
and does nothing for .html file (e.g. http://www.tranquillizer.co.uk/phptest.html)

AddType x-mapp-php4 .html .htm (suggested by web host)
results in some pages as Error 404 not found (pages for which the link has no extension I think)


My server is with 1and1, and so far they have not given a response to my problem. As a last resord I will have to rename all pages as .php and set up permanent redirects, but I have been informed that this may affect page ranking etc.

Does anyone have any suggestions? I do not have access to the Apache config files with my webhost.

If you are with 1and1 and have done this, please let me know !

Thanks,

Jon.


Sun Nov 12, 2006 2:47 pm
Report this post
Profile
Junior Member

Joined: Wed Mar 07, 2007 4:54 am
Posts: 1
Post To parse html pages as php
Hi jonwade,

You want apache to parse html as php right? This can be set by putting the following code in ".htaccess"

1. edit .htaccess file

2. AddHandler application/x-httpd-php .php .html

This will do the trick.

If you want more extension to be parsed as php you can add as much

eg:

AddHandler application/x-httpd-php .php .phtml .html .htm .shtml .cgi .pl .asp .dll


Regards,
Karthikeyan.R


Wed Mar 07, 2007 5:01 am
Report this post
Profile
Junior Member

Joined: Sun Jun 03, 2007 12:41 am
Posts: 1
Post 
hans51 wrote:
if you still have that problem open until now
i was hosted at 1and1.com until october 2006 and had it all successfully running until 1and1 ran out of resources and i moved to root server

i checked one of my old backups for u and found my entries in .htaccess

AddType x-mapp-php4 .html .htm .shtml
removeHandler server-parsed shtml


if u have php5 then you have to change first lien above accordingly

good luck


I found this page thru google, looking for better info about the "application/x-httpd-php" type found on other sites, but I couldn't make it work. The above lines worked perfectly on my shared server at 1and1. Thanks hans51!


Sun Jun 03, 2007 12:49 am
Report this post
Profile
Junior Member

Joined: Tue Nov 06, 2007 4:37 am
Posts: 1
Post 
Vladimir,

How would one do what you suggested?

I have a bit of a different problem, but somewhat the same, LOL

I have a site I am changing over from ssi to php I would like to keep the .shtml file name as they are indexed well. When I place

Addhandler application/x-httpd-php .html .php .shtml

in .htaccess, php is of course parsed just fine. The problem is that the pages that still use ssi are not functioning. I don't have time to get all the pages done at once, it is a process that is going to take a few weeks.

IF I add the .shtml to the list above, it won't put the ssi in, but if I leave it out, it will not parse the php on the .shtml pages that are updated with php includes.

Is there any way to get the .shtml pages to provide the server side includes OR the php includes while using the .shtml extension?

You can see it at Sustainable organic gardening for food.

The site is hosted running php5.2.4 and Apache 1.3.39


Tue Nov 06, 2007 5:01 am
Report this post
Profile
Junior Member

Joined: Sun Nov 12, 2006 2:43 pm
Posts: 3
Post 
Hi GardenSimply,

It has been 3 years since I used this method and now use a CMS to manage my URLs and content.

If you need to update but want to retain the pagerank/listings of your current pages just redirect them with this in the htaccess:

Redirect 301 /organic-gardening-tips.php http://www.gardensimply.com/newpage.whatever

Build your site using the nest method and use the 301 redirects to pass your pagerank on to new pages.

It is most likely possible to rewrite, but I was never any good at that myself!

_________________
Web Design in Essex


Wed Nov 25, 2009 6:55 am
Report this post
Profile
Junior Member

Joined: Sun Nov 12, 2006 2:43 pm
Posts: 3
Post 
ffghjuoio wrote:
I have a site I am changing over from ssi to php I would like to keep the .shtml file name as they are indexed well.


As I just mentioned above, do not worry about the indexing. If you 301 Redirect he pages then the indexing will update and you will not lose any traffic. I have upgrades many sites using this method and it has only ever resulted in an improvement in indexing.

_________________
Web Design in Essex


Thu Nov 26, 2009 1:28 pm
Report this post
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.