3

I recently played with a .htaccess file to make one server to parse PHP files. Yesterday I uploaded the same .htaccess file and tried to test a PHP file. But something went wrong: visiting my page the browser offers to download the the html page rather then viewing the page!

On the server the filenames end in .html.

I added the following to my .htaccess file:

AddType application/x-httpd-php .html

I tried to find the htaccess file, but once uploaded it just disappears from the root dir. I tried to upload other scripts I've found browsing. I even tried to search for some problem on a hosting forum. Nothing helped. Please help!

2 Answers 2

5

Try this

AddType application/x-httpd-php .php .htm .html

OR

AddHandler application/x-httpd-php .php .htm .html

And remove other overriding handlers for application/x-httpd-php after above code.

Sign up to request clarification or add additional context in comments.

6 Comments

I don't think that is the problem, and if he doesn't use .php or .htm extension then there is no need to...
Thanks! but how to remove if I can't see any htacces folder or file eather. See @Cyber-Guard Design's answer. May I try just to re-upload a .htaccess file with this codes?
And yes, I removed the test php i've tried to explore, now I just need to undo changes. Seems like mission impossible
Please correct your spelling of tryed its tried, It should be ok in .htaccess
The AddHandler application/x-httpd-php .php .htm .html HELPED! But only if i write www.roko.x10.mx/index.html , otherwise it won't open again
|
2

Right, firstly things first, what host do you use?

Also what ftp client you are using? Some by default won't display files starting with . such as .htaccess and .htpasswd, that's why it may appear that you didn't upload it. Also it might be that you don't have the rights to upload in the very root directory, try to go one directory up.

Also from my experience, hosts won't allow you to modify headers via .htaccess this way, because the allowoverride directive is off; instead have a look at url rewrites (via mod_rewrite), which allow you to do the same thing without modifying headers.

Your rewrite .htaccess file might look something like:

RewriteEngine On
RewriteBase /
RewriteRule ^(\w+)\.html$ $1.php [NC] 

(Not tested though) Using a rewrite will also mean that your files will in fact maintain the php extension, however they will be access via urls that include .html extension.

1 Comment

strange... after I applyed all the changes, and waited a day... now everything works fine! THANKS for the suggestions and help!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.