ultrasound0000 Posted March 18, 2009 Share Posted March 18, 2009 Hi folks, I recently changed my site from html to php. For SEO purposes (can't lose page rankings by doing 301 redirects), I want to keep all my files as html for the time being. Is there a way to configure Apache to interpret the html pages with the php interpreter? Any idea how this is done, htaccess maybe? Also, any drawbacks to this approach? Quote Link to comment https://forums.phpfreaks.com/topic/150000-solved-htaccess-make-html-extension-files-to-be-interpreted-with-php-interpreter/ Share on other sites More sharing options...
drisate Posted March 18, 2009 Share Posted March 18, 2009 I am not a htacess pro, but yu can try something like this RewriteRule ^example\.html$ example.php Quote Link to comment https://forums.phpfreaks.com/topic/150000-solved-htaccess-make-html-extension-files-to-be-interpreted-with-php-interpreter/#findComment-787756 Share on other sites More sharing options...
souless87 Posted March 18, 2009 Share Posted March 18, 2009 AddHandler application/x-httpd-php5 .html OR AddHandler application/x-httpd-php .html Quote Link to comment https://forums.phpfreaks.com/topic/150000-solved-htaccess-make-html-extension-files-to-be-interpreted-with-php-interpreter/#findComment-787759 Share on other sites More sharing options...
ultrasound0000 Posted March 19, 2009 Author Share Posted March 19, 2009 Thanks Souless87 for the info. I tried your code on my htaccess file but for some reason not getting it to run as PHP. Am I missing something? I even removed everything else on my htaccess and left just this line of code but still when I go to an html file that has PHP code in, it doesn't work (browser only displays html). Quote Link to comment https://forums.phpfreaks.com/topic/150000-solved-htaccess-make-html-extension-files-to-be-interpreted-with-php-interpreter/#findComment-788494 Share on other sites More sharing options...
PFMaBiSmAd Posted March 19, 2009 Share Posted March 19, 2009 It should be - AddType application/x-httpd-php .html Quote Link to comment https://forums.phpfreaks.com/topic/150000-solved-htaccess-make-html-extension-files-to-be-interpreted-with-php-interpreter/#findComment-788505 Share on other sites More sharing options...
ultrasound0000 Posted March 19, 2009 Author Share Posted March 19, 2009 @Souless87: Nevermind, it actually worked with the AddHandler application/x-httpd-php .html code that you provided. I found out my webhost (dreamhost), was re-writing my htaccess file each time. @PFMaBISmAd: what is the difference between Addtype and AddHandler in this case? I got it to work with AddHandler, but just curious Quote Link to comment https://forums.phpfreaks.com/topic/150000-solved-htaccess-make-html-extension-files-to-be-interpreted-with-php-interpreter/#findComment-788510 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.