FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


How to change extension php to html but the php script still





Philip
How to change extension php to html but the php script still work ? i see on some sites there is phpbb work with html extension
cann some explain it for me ?
Atomo64
If you have access to the web server setup then you can make PHP parse html files so you can actually use .html as the extension but still being able to use PHP code.

Otherwise you have to use Apache's mod_rewrite, you just need to create a new .htaccess file and put something like this:

Code:

RewriteEngine on
RewriteRule ^somepage\.html$ some_script.php [L]
mathiaus
Atomo64 wrote:
If you have access to the web server setup then you can make PHP parse html files so you can actually use .html as the extension but still being able to use PHP code.

Place this into your .htaccess file in the directory you want it to affect
Code:
AddType application/x-httpd-php .html



Philip wrote:
i see on some sites there is phpbb work with html extension
cann some explain it for me ?

That would be done using url rewrite. For example the link to this topic is http://www.frihost.com/forums/vt-45388.html but the actual page is http://www.frihost.com/forums/viewtopic.php?t=45388 so a line like
RewriteRule ^vt-(.*)\.html$ viewtopic.php?t=$1 [L]
Philip
any way is that more secure ? or not ?
so i just need to upload .htaccess files with those code as content right ?

and this code
RewriteEngine on
Code:
RewriteRule ^somepage\.html$ some_script.php [L]

and
Code:
RewriteRule ^vt-(.*)\.html$ viewtopic.php?t=$1 [L]


Can some explain it for me, what's that mean ?

thanks.
Atomo64
mathiaus wrote:
Atomo64 wrote:
If you have access to the web server setup then you can make PHP parse html files so you can actually use .html as the extension but still being able to use PHP code.

Place this into your .htaccess file in the directory you want it to affect
Code:
AddType application/x-httpd-php .html

of course that will only work if the server configuration lets you do so, because of permissions Wink
Philip
glek, so i need to contact my provider first uh ?
avk
Hey! Just check the PHP manual.. it is there in real good and easy words..
Philip
avk wrote:
Hey! Just check the PHP manual.. it is there in real good and easy words..


hey, where can i check the manual ?
i think it isn't about php again anywhere,~
PatTheGreat42
The solution to what you're asking does indeed have nothing to do with PHP. If you want to do that, it's a server thing. Basically, you're telling the computer that .html really means .php, so it acts accordingly.

But why would you want to do that? So people on your site think that instead of cool scripting, you have worker elves customizing your site with every download?
Philip
it;s not just about cool or what, it;s about knowledge Smile
if someone dunno about something, better ask than... lalala lolz
Aredon
It's called Server Side Includes (SSI).

mypage.html:
Code:

<p><!--#include virtual="/helloworld.php" --></p>


helloworld.php:
Code:

<?php
echo "Hello World!";
?>


Then create a file called "htaccess.txt" and upload it to your FTP:
Code:

AddHandler server-parsed .html

Once it's in your FTP, rename the file from:
Code:

htaccess.txt

info:
Code:

.htaccess

No that is not a typeo. Files with no file name and a leading period are special files.


That's it! Give mypage.html a run.
Related topics
[tutor] How to protect images without htaccess using PHP
Hot or Not PHP-Nuke script
What's the best PHP Wiki script?
[php]putting script fragments together?
Can frames be a good choice? What then?
Php voting script needed (URGENT)
php/HTML pages question
150 frih to make this SIMPLE script
PHP script problem
PHP contact script...
Embed PHP+HTML
need help in a simple php register script based on flat file
Climate change data
consistently get different script errors when logged in
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.