Friday, 30 January 2009

Using mod_rewrite to change your file extensions from PHP to HTML on 000webhost

I was messing with mod_rewrite to change file extensions on 000webhost, but the code I usually use was not working. 000webhost is the free service I use for my website from which you may have come from. For reasons that I have not been able to determine, the .htaccess file I usually use was not working on the host and was instead giving me errors.

Fortunately, I was able to turn all my .php extensions to .html by writing a new piece of code, that strangely works on 000webhost but not on XAMPP.

The code I used is as follows:

Options +FollowSymLinks

RewriteEngine On

RewriteRule ^([^.]+).html$ /$1.php [QSA,L]

This will hopefully solve your problems. Do not forget that your .htaccess file needs to be uploaded to public_html folder and not to the root.

No comments: