Hiya guys.

This maybe a very stupid question, but, I've searched everywhere for a possible solution.

Sometimes when I log out or try to access the index.php page, the browser tries to download it as opposed to opening it. i.e. sometimes a dialog box appears saying "downloading file" and it downloads index.php, asks if I want to open/close or cancel. When I click on open it, it says it doesn't know what to do with the file.

Am using drupal 4.4.1
on an apache server.
don't have access to php.ini on my server and am not using htaccess

Whats bugging me is that the error seems random. I can't recreate it consistently which would normally help deduce or indicate where the error is originating.

Any guidance, regardless of how simple it may appear appreciated.

Cheers

Jason

Comments

Dublin Drupaller’s picture

Hiya again...

I think I have located the problem, but still need assistance/guidance/pointers.

Sometimes, for example when I log out, the browser starts a downloading file procedure..i.e. instead of opening up the configured default front page, it starts to download the file...

When I save the file as a text file an open it up in a text editor, this is what I see:

I'm not an expert by a long shot, but, thats an indicator that there is a problem compiling the html does it not? i.e. theres some of those binary type characters in there that I see sometimes in a file when accidentally uploading it to a server in binary instead of ascii format. You know..the box character where a line break should be. I tried pasting it in here, but it won't let me..suspicious content error. these binary block characters are only in the first half of the problem download.

Hope this rings some bells with some of you guys out there..ripping my hair out on this one (whats left of my hair...!! Baldness is hereditary, you get it from your children)

Cheers

Jason

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate

Dublin Drupaller’s picture

Hiya again..

After a bit of newbie troubleshooting, I found that if I switched the Cache off in the configuration page it stopped the problem I was having.

Under CACHE - I selected DISABLED.

Now the site is accessable without the binary data problem I had earlier.

Am trawling through the forum/help to see if there is a common cache problem. Will post back up here if I find it in the hope it is of use to someone else who has had a similar problem.

If any1 out there has been there done that with what I'm talking about, please drop a quick reply..

Cheers

Jason

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate

Dublin Drupaller’s picture

Hi yet again...

Aren't most browsers automatically switched to cache pages and content?

So by disabling cache in the configuration page (using drupal 4.4.1) it makes no difference...i.e. with cache enabled in the configuration page it is "doubling-up" the cache-ing the browser is already doing automatically....

Am i right in thinking that or should I am I complete and utter retard?

Jason

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate

cramhead’s picture

Hi Jason,

I'm thinking that the php interpretor is not executing the code.
If you look at the text that it downloads and there php in there then you know that it is not interpreting it, as otherwize it would be html.

Good luck
marc

Dublin Drupaller’s picture

Hi Marc,

Thanks for the message. was wondering if I was just talking to myself.

Not so sure the php interpretor not working being the source of the problem. Since disabling Cache..the problem hasn't re-occurred.

Is there a simple way (I'm a newbie) of testing the php interpretor?

Cheers

Jason

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate

santosh2017’s picture

Hi,
I am facing the same issue with opening a php page on my local machine.
It opens in the browser without a problem.
But when I change it a little bit in notepad++ , save and close it.
Opening it in the browser now gives the open/save popup dialog.
Even I think there are some hidden characters in the saved file. But comparing in beyond compare shows that both files as same.
I will try to check by disabling cache though the root cause is still unknown.

BR
Santosh

mtemar’s picture

Hi Jason,

How did you manage to fix your proplem ->Index.php starts to download instead of opening...

I'm having the same problem too.

Matt

"The earth is one country and mankind it's citizen"

boytroy88’s picture

A few posts above mentions that it might be php not working and I tend to agree. You could write a quick php page to test it. Just put the following:

&lt?php
phpinfo();
?&gt

into a file with a php extension and upload to your webserver and then run it (i.e. - &ltyoursitename&gt/&ltdirectory&gt/phpinfo.php assuming you named the file phpinfo.php).

If you get information about your php server then your php server is running ok. If it starts to download again then for sure your php server is not running and you should see whether the php server is up or not and go from there. Hope this helps!

Dublin Drupaller’s picture

Hiya Matt,

It's a while ago I fixed the problem. As far as I can remember I switched off or disabled the cache support in the settings conifguration page.

Hope that works for you. Haven't had the problem since changing that. Nothing to do with PHP not interpreting the code properly.

Jason

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate

ixis.dylan’s picture

I've had this problem lately, too. It happens all the time if I enable zlib/mod_gzip compression in my htaccess, but only for pages served from the (compressed) cache. This suggests that pages are being compressed twice.

That doesn't really answer your question, because I think the gzipped cache is a recent addition, but at least we share the same symptoms.

mwu’s picture

I'm having this problem.

i get the text file index.php instead of it being interpreted.

if i do phpinfo same thing.

i was trying to make clean urls work but I thought I restored the original httpd.conf file

EDIT: the issue went away. I don't know why. two things you can try.
closing the browser.
restarting apache.

Robert de Bock’s picture

I think I found the solution:

1 - Move the old .htaccess away:
mv .htaccess .htaccess.old

2 - Place a newly extracted .htaccess.
mv /tmp/some/where/.htaccess .

This solved the problem for me, not the en- or disabling cache.

Robert de Bock
http://meinit.nl/

davemybes’s picture

This is an old thread, but comes up in searching for this problem. So here's another solution, this time for Drupal 6. Simply turn off Page Compression in the Performance settings, clear all your caches, and the front page should load OK. Note: this was only happening on the front page, not on other pages, which loaded fine. Oddly, if I used www. in front of the URL, it was fine too.

______________________________________________________________________________________________________

Winn’s picture

Using some of the techniques listed above, I solved the problem, but didn't realize it for awhile due to my browser's cache of the page.

So, after you try a fix, CLEAR YOUR BROWSER'S CACHE!

Jabouty’s picture

So apparently I was able to fix this, but although the browser cache was continuously cleared after each attempt, the problem kept appearing.

Turns out the reason for this is the following lines in the .htaccess:

# Requires mod_expires to be enabled.

# Enable expirations.
ExpiresActive On

# Cache all files for 2 weeks after access (A).
ExpiresDefault A1209600

This told my work proxy to cache the messed up page for the next two weeks ... yay ...

The page works fine now off the work network, but for now (until the proxy recaches) I simply point directly to index.php when hopping to my drupal domain.

Good luck to anyone else having this issue.

-Jab

DocDJ-forum’s picture

I found those same "expires" values in my .htaccess file and tried to go directly to /index.php, but it still thinks it's just a file to download.

regards,
DJ

alfista’s picture

On my local machine everything works fine. My browsers (any of them) opening localhost/drupal start page but from another machine and network the browser starts to download the index.php without to recognize the file extension and asks for application to open it...
By the way, could not find where to turn of the cache in drupal...

bennyelless’s picture

One page would behave like it should, returning HTML, but another in the same directory was returning the PHP as a download. I completely reinstalled my LAMP, but the problem still occured. It didn't stop until I cleared my browser cache. Thanks for the tip!

franck22’s picture

another solution that worked for me was moving
application/x-httpd-php php php5
at the bottom of the mime.types while I was placing it on the top

graebryan’s picture

Hi all,

My host server added AddHandler command to the bottom of my .htaccess file and so when I put it on my laptop is was downloading any php file instead of executing it.

AddHandler application/x-httpd-php56 .php .php5 .php4 .php3

Removing this code solved the problem.

Make sure you check your .htaccess file and compare it to an unaltered one out of the repository.

I hope this helps someone.

Graeme

sukh.singh’s picture

Thank @graebryan it worked for me.

ojchris’s picture

You were very right. the added htaccess file in the root directory of drupal 8 also added stuff about a ".well-known" directory. The .thacess file in the web directory was unchanged.

Resolving this took over 5 hours of my time. Thank you for the direction

fabrizioprocopio’s picture

Same issue.

I changed the php version for that site from 7.1.33 to 7.2.29 and everything is back up and running.

Hope can help someone.

rl347’s picture

Just to reinforce Graeme's post - the problem, for me, was I copied a site from Host to Local and the host set domain-related php version by adding a handler 'AddHandler application/x-httpd-ea-php74 .php .php7 .phtml'.  Presumably this failed in the local Wamp (in my case Laragon), so php files were served as text.  Three wasted hours, too!  Ron