Reply
php extension to html
Old 05-25-2008, 04:44 PM php extension to html
Red_X_'s Avatar
Super Talker

Posts: 104
Location: USA
How do you go about making a .php to .html(change the extension in the browser)

example:

Default: site.com/index.php
want: site.com/index.html

Obviously i'll be using php. I just want to spoof it up I guess.

Thanks for your help,

Red_X_
__________________
>> Higher a poor college student. PM me :). PHP/MySQL <<
Red_X_ is offline
Reply With Quote
View Public Profile Visit Red_X_'s homepage!
 
When You Register, These Ads Go Away!
Old 05-25-2008, 06:17 PM Re: php extension to html
rogem002's Avatar
Webmaster Talker

Posts: 611
Name: Mike
Location: United Kingdom
I think what you need is an apache rewrite instead of php (php just processes the page and not much more).

For example, in your .htaccess put the following:
Code:
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*).html$ $1.php [QSA]
Essentially, if someone wants site.com/index.html the server would access site.com/index.php and the user would have no idea.

If that seems a bit wasteful/insecure, you could also add an extension handler. Again in .htaccess put the following:
Code:
AddHandler application/x-httpd-php html
In this one, any file that ends in .html will be run as a php file.

A extension handler is a much more simpler way of doing things and you will not have 2 files (in a sense) floating about. It's up to you though
__________________
PHP Code:
Add_Talkupation('rogem002'); // Because sharing is awesome! 

Last edited by rogem002 : 05-25-2008 at 06:21 PM.
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Reply     « Reply to php extension to html
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11957 seconds with 12 queries