PHP doesn't execute but downloads code

Okay, new here but have been using PHP for several years. This is a new one for me. I just reinstalled WAMP 64 vers 3.2.2.2 w/ SQL and PHP 7.3.12. I have 2 ‘websites’ on my PC localhost server - one executes the PHP perfectly. The other only downloads the code as a file. I’ve had several websites within WAMP and never had this issue. The PHP code works properly in one website, but downloads on the other. Help!

Have you got a .htaccess file on the website that is downloading?

Thanks. Nothing in the .htaccess file. BUT, I have discovered if I use .php3 extension on my PC, the code will run, but when I send it to the webserver, it fails and downloads and even questions if I want it to download as it might be risky. The .php code will run on the webserver. Hm? I certainly don’t want to write the code as .php3 to work on it and then have to rename everything to .php before I upload it to the live server.

To try and get my head around it:-

Is your directory structure like this:-

wamp
| www
–|website1
–|website2

And when you go to

127.0.0.1/website1 it executes

But when you go to

127.0.0.1/website2 it downloads

Yup, you got it right. Weird, right? c:\wamp\www\site1 - works; c:\wamp\www\site2 - downloads. On site2 all html works, just the php code downloads.

Maybe I should clarify - if the extension is php, it downloads; if it is htm or html, it executes on site2. Everything works on site1.

Sorry for the late reply, , When you say there is nothing in htaccess do you mean its a blank page or is there a line with “AddHandler .php7”

This is what is inside .htaccess for the site that is wonky - .htaccess for the working site has all my hidden directories info only. I really appreciate the help - I’m struggling forward right now using whatever to get the code written and at least tested before editing it for the live server.

php – BEGIN cPanel-generated handler, do not edit

Set the “ea-php73” package as the default “PHP” programming language.

#

AddHandler application/x-httpd-ea-php73 .php .php7 .phtml

#

php – END cPanel-generated handler, do not edit

Well, what I posted looks crappy. Each line is preceded by a # which means it is ‘rem’ not to be executed - right? I attempted to remove all the code and try - no difference.

Okay, I just deleted “.htaccess” and created a new file “.htaccess” Hm? Everything seems to work now. I really appreciate your input and assistance. Still not sure what the issue was, but things are working. Again, thanks a million for the help.

Sponsor our Newsletter | Privacy Policy | Terms of Service