Openserver download page, but it must load it - php

I have installed OpenServer program to modify old company WordPress site locally.
So old WP page was on 5.6 PHP version, and put the same in OpenServer settings.
But program doesn't load page, but always try to download some "download" file. If try to open that file in notepad, it looks like usual index.php (what load WP).
So i played with .htaccess, server see it, but cant load php by some reason.
Same way i created clean WP doimain folder, what works. And just if i change php and apache version it didnt see MySQL DB.
What it may be ? If you need some screens, i can make them.

Problem was in .htaccess file.
By default it was ->
AddHandler application/x-httpd-ea-php56 .php5 .html
I was changed it to ->
AddType application/x-httpd-ea-php56 .php5 .html
Page loads now correctly by browser.

Related

file .htacces AddType not working annymore

Since a few days, my website is no longer working, instead of displaying the site, it downloads the source code(the file is called 'download' without any extension). After some digging it appears to be the .htacces file, the 'AddType application/x-httpd-PHP .html .htm' rule.
When removing, it works fine(when i rename the .html file to .php manually). However, my site relies on this rule, because all my files are called .html and renaming everything to .php isn't really an option.
It has worked fine for months.
The information I know:
Php version : 5.6.38
Web server: apache/2

After setting .htm files to render using PHP I'm being asked to download the page

I'm working on an old site, and I want to add cookie functionality in order to allow people to use the mobile site, but also opt-into using the full site if they want. The site is currently all .htm files, and I can't with the budget go in and change every link to .php so I tried adding this to my .htaccess file
AddType application/x-httpd-php .htm
This is causing the browser I'm using (Firefox) to ask me to download the file. It says it's a application/x-httpd-php file, so I know the .htaccess file is working. When I was building my home web sever, and trying to run a ruby on rails site I ran into the same problem because i hadn't set up ruby correctly and it wasn't rendering the file. But I have never run into a site that doesn't have some sort of support for PHP. Could this be caused by another problem. Or does that .htaccess file change break rules made by some web hosts?
Any support would be amazing! Thank you so much everyone :)
You need to add a handler for that type, otherwise the webserver isn't going to do anything with it:
AddHandler application/x-httpd-php .htm
That should be enough if you've already got phpv4 executing on your server. But you can also create a custom action explicitly:
AddHandler application/php-cgi .htm
Action application/php-cgi /path/to/php-handler

htaccess downloading file instead of loading

I would really like my index.html to be able to have a PHP script work on it. I read that you can do this through the htaccess file. I only have access to a subdomain website directory, where I can upload my files through FTP.
The directory did not have a htaccess file, so I created one using notepad: .htaccess and added this to the file:
AddType application/x-httpd-php .html
The problem is, instead of loading the index.html page, it downloads it as a file...would I need to add something extra to the htaccess file? :S
You don't need to name the file index.html to have it served by default. You can change the default document using your with an entry in your .htaccess file like this:
DirectoryIndex index.php
Then when you navigate to http://yoursubdomain.example.com you will be served index.php instead of index.html.
If really do want PHP to interpret your .html documents then the entry you had in your question will work when PHP is running as an Apache module. If your host is running PHP as CGI, you want:
AddHandler application/x-httpd-php .html
If it still doesn't work, then this web page has some more suggestions:
http://www.velvetblues.com/web-development-blog/how-to-parse-html-files-as-php/
The directive you have sets the content-type of files with a .html file extension.
If the server has PHP installed and enabled, that content-type will cause it to be run though the PHP engine and then the output from that sent to the client.
If it doesn't have PHP installed, then the file will just be served up to the client with that content-type. Since browsers don't handle PHP scripts themselves, they will then just save the file.
You need to install and enable PHP as well as setting the content-type.
Presumably your hosting is supporting PHP?
If so, then you need to rename your file from index.html to index.php

Server Downloading File Instead Of Showing It

I have a Apache server running at Rackspace Cloud Hosting, so I've installed Wordpress manually(setting up the database, wget the latest.zip...) and placed it at /var/www, but now when I try to access it for the first time, it downloads a strange file with the IP as name instead of showing me the Wordpress Installation.
PS: The same happens if I place it on a sub-directory like blog
I think you haven't configured Apache to execute PHP (mod_php?) Right now it's just serving your PHP files like any old file type so what you're getting is your wordpress index.php as a file download.
I'm not sure what the process is for Rackspace, but usually this would mean enabling mod_php.
Do you have any other PHP files that work on that site?
you need to tell Apache to excuate php files. add the following to your Apache configuration file:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .php
make sure PHP module is included in Apache configuration first!

Apache not handling files correctly (Handler Help)

I'm trying to set up my .htaccess file correctly and I'm having an issue.
The only thing my .htaccess file at the moment is:
AddType application/x-httpd-php .php .html .htm
This is included because my server is not parsing php in my html files.
However when this is included in my .htaccess file, when I open a page in my browser, the user is prompted to save or open the file locally.
I believe the answer to my issues is setting up an action to be done (run with php) however I cannot find out the path to my php files.
Any help is appreciated.
You will need to edit the configuration for enabled modules. On a Debian/Ubuntu type system this will be in /etc/apache2/mods-enabled The file you are looking for is php5.conf
So far all you have done is specify that (dot) htm, html or php files should be served -by default- as application/x-httpd-php, and to my knowledge there is not a single web browser that would attempt to interpret such content -- hence the save-as dialog.
Either you could fix your .htaccess file not to be broken (it is broken behaviour to serve html files as application/x-httpd-php), or you could manually output the correct HTTP headers using the PHP header() function.
Unfortunately, everyone seems to love abusing AddType (and then complain e.g. that MultiViews is broken). See this article, please.
This is not supposed to work in all cases. It depends on the AllowOverride directive of the web server.
You shoud specify the AddType in the serveur config file rather than in the htaccess.

Categories