4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 Quick Tip: Use PHP on .HTML files
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sun Sep 22, 2002 6:01 pm (15 years, 1 month ago) Reply with QuoteBack to Top

Ever wanted to keep your files ending in .html (that's the way they were before, or you want to have them like that because it "looks better" Wink)?

If so, here's a little tip. It only works with Apache, but most servers use Apache anyway Mr. Green

Put the following text in a file called ".htaccess" in the root of your site:

Quote:
<Files *.html>
ForceType application/x-httpd-php
</Files>


That's it!

Your .html files should now be parsed by PHP.

To do the same with any other files, just replace
Quote:
<Files *.html>
with
Quote:
<Files *.whateveryouwant>

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
adam
Forum Moderator & Developer



Joined: 26 Jul 2002
Posts: 704
Location: UK

PostPosted: Tue Sep 24, 2002 6:20 pm (15 years ago) Reply with QuoteBack to Top

you could do this with less code, simply:
Code:

AddType application/x-httpd-php html inc cuo


This would make *.html, *.inc and *.cuo be parsed through PHP.

________________________________
It's turtles all the way down...
OfflineView User's ProfileFind all posts by adamSend Personal MessageVisit Poster's Website
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Tue Sep 24, 2002 6:23 pm (15 years ago) Reply with QuoteBack to Top

Laughing Yes, that's true. But my example can be more widely used, as you can use it for only one file: Razz

Quote:
<Files blabla.html>
ForceType application/x-httpd-php
</Files>

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
adam
Forum Moderator & Developer



Joined: 26 Jul 2002
Posts: 704
Location: UK

PostPosted: Tue Sep 24, 2002 8:31 pm (15 years ago) Reply with QuoteBack to Top

well, then it depends on your specific situation...

not sure why you'd need to use it on just one file though...

________________________________
It's turtles all the way down...
OfflineView User's ProfileFind all posts by adamSend Personal MessageVisit Poster's Website
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Wed Sep 25, 2002 5:31 am (15 years ago) Reply with QuoteBack to Top

Well that's what we're having to do at 4WebHelp, because we have some files which have no extension Smile

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
php4ever
Junior WebHelper
Junior WebHelper


Joined: 10 Oct 2002
Posts: 49

PostPosted: Fri Nov 08, 2002 6:31 am (14 years, 11 months ago) Reply with QuoteBack to Top

I took Daniel's suggestion and put the Force Files directive in my .htaccess file so that all the html files at my site can contain php which will be parsed. But, tonight I noticed that I have one subdirectory that really needs to be exempt from this directive. So, how do I remove the <FORCE FILES> directive for just one subdirectory? I tried 'RemoveType application/x-httpd-php .html' and that didn't work. Any suggestions?
OfflineView User's ProfileFind all posts by php4everSend Personal Message
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Fri Nov 08, 2002 4:32 pm (14 years, 11 months ago) Reply with QuoteBack to Top

Maybe
Code:
AddType application/x-httpd-php php
would work? Question

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
php4ever
Junior WebHelper
Junior WebHelper


Joined: 10 Oct 2002
Posts: 49

PostPosted: Sat Nov 09, 2002 6:11 am (14 years, 11 months ago) Reply with QuoteBack to Top

Thanks, Daniel, I tried what you wrote above but it didn't work. If you have any other thoughts, pls let me know.

--php4ever
OfflineView User's ProfileFind all posts by php4everSend Personal Message
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sat Nov 09, 2002 7:44 am (14 years, 11 months ago) Reply with QuoteBack to Top

Not sure if this works, but try
Code:
ForceType text/html


It's worth a try Wink

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
php4ever
Junior WebHelper
Junior WebHelper


Joined: 10 Oct 2002
Posts: 49

PostPosted: Sat Nov 09, 2002 11:48 pm (14 years, 11 months ago) Reply with QuoteBack to Top

Daniel, tried your latest suggestion in re ForceType but that didn't work either. Sad
Again, thanks for trying to help; I appreciate it.
OfflineView User's ProfileFind all posts by php4everSend Personal Message
adam
Forum Moderator & Developer



Joined: 26 Jul 2002
Posts: 704
Location: UK

PostPosted: Sun Nov 10, 2002 1:49 pm (14 years, 11 months ago) Reply with QuoteBack to Top

if you used the force type thing for .html, try using just .htm for the files in that directory...I know it'll mean a lot of renaming and link changing...but it's all I can think of Very Happy

________________________________
It's turtles all the way down...
OfflineView User's ProfileFind all posts by adamSend Personal MessageVisit Poster's Website
php4ever
Junior WebHelper
Junior WebHelper


Joined: 10 Oct 2002
Posts: 49

PostPosted: Mon Nov 11, 2002 7:25 pm (14 years, 11 months ago) Reply with QuoteBack to Top

adam wrote:
if you used the force type thing for .html, try using just .htm for the files in that directory...I know it`ll mean a lot of renaming and link changing...but it`s all I can think of Very Happy
Adam,

Thanks for your suggestion. It does sound like a feasible solution -- and one that requires merely dropping one letter! However, as you note there is the tedium factor. There is also another way to resolve the problem that is also tedius -- replacing each '<?' in every file with &lt;? Looks like the solution here will either way involve being less lazy than I'd like to be! Wink
OfflineView User's ProfileFind all posts by php4everSend Personal Message
tarianz
Junior WebHelper
Junior WebHelper


Joined: 10 Aug 2012
Posts: 1

PostPosted: Fri Aug 10, 2012 5:01 pm (5 years, 2 months ago) Reply with QuoteBack to Top

Thats works correct for me ))
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddType application/x-bittorrent .torrent
bates methodглаукома
OfflineView User's ProfileFind all posts by tarianzSend Personal MessageVisit Poster's Website
runescapevip
Junior WebHelper
Junior WebHelper


Joined: 16 Nov 2014
Posts: 3

PostPosted: Sun Nov 16, 2014 7:58 am (2 years, 11 months ago) Reply with QuoteBack to Top

FIFA online involved new material administrator technique is fairly Aspect within this version, as football lovers player from the FIFA sequence, the identical because the EA representative features of football administrator is certainly no stranger to be able to Fifa Coins enrich and enhance the encounter ways casual sex.
OfflineView User's ProfileFind all posts by runescapevipSend Personal Message
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




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 vote in polls in this forum.


Page generation time: 0.07258 seconds :: 17 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme