A while ago, I started having a problem where every few days, my Wordpress site would crash. Instead of loading, the site would just download the contents of index.php.
After some investigation, I found that commenting out the following line in the .htaccess file solved the issue:
AddHandler application/php-70 .php
However, my comment on that line keeps getting over-written somehow.
So here are my questions:
Why is that line causing the issue, and can the root cause be addressed?
If the root cause can't be addressed, how can I prevent my comment on that line from being overwritten?
If I can't prevent the comment from being overwritten, can I add some sort of monitoring to show my what's causing changes to the .htaccess file?
Additional info:
Wordpress 5.4.2 on SiteGround hosting
Seems like some plugin is overwriting your changes in .htaccess, check this link https://wordpress.org/support/topic/php-version-change-can-break-htaccess which addresses a similar problem.
Also, you can follow the instructions here https://www.siteground.com/kb/how_to_have_different_php_versions/ and you should (if you can) change/upgrade your php version to the required version.
Alternately, you can chmod 655 .htaccess file to disable any plugins writing to it.
Related
Now this site (removed) was running well until few hours ago when I tried importing demo content for my wordpress template. I got the "fatal error maximum memory exceeded" thing and decided to tweak the .htaccess file: That was when my travails began. I've tried all possible solutions ranging from deleting the whole site plus database and what not?
So, I decided to test if this error is extension related, so I uploaded an html file and tried accessing it...Voila! it opened! I tried other file extensions (css,jpg etc) everything opened except files ending with the extension ".php". What do you think could be responsible for this?
Note: I've tried increasing the php memory limit by creating a php.ini file, nothing changed.
Thanks
Well, after messing around with the site's FTP, I realised that the permission of the folders (including public_html) has been mysteriously set to 0777. Changing them to 0755 fixed my problem.
I have a project hosted on Hostgator. I need PHP 5.4 so, as they require, I add the following line to my .htaccess file:
AddType application/x-httpd-php54 .php
The issue is that with this line, any URL throws an error 404. Without this line, everything works fine - but with PHP 5.3 only.
I'm at a loss to understand how this line and error 404 are connected. Anyone has an idea?
It's the php.ini file, probably located in your root user folder. You have to remove/rename it. There is a php.ini incompatibility between 5.2ish and 5.4.
Also, I've never been able to get AddType to work. I've always had to use the older AddHandler.
On a side note, doing some more playing around in the php.ini, I figured out that register_globals=On was causing my 5.4 to hickup. I thought it was shut off, but I guess not... I changed it to off and my phpinfo page came alive.
And even more testing against my original php.ini file, I learned that: "allow_call_time_pass_reference = On" must be commented out...
Long story short, check your user php.ini files...
Recently I moved a website to a new server. The website was working perfectly on the shared server, but I've encountered a host of permission issues and other problems since relocating to EC2. I have changed the ownership of the /var/www/html folder to apache to allow altering altering of settings on the back end of WordPress. Strangely enough, I am able to create new posts, but when I attempt to update an existing page or create a new one, I receive a blank page. [http://example.com/wp-admin/post/php] Originally I thought it was yet another permission based issue, but after researching that doesn't appear to be the case.
Steps I've taken thus far:
1) Changed ownership of the directory to apache
2) Disabled all my plugins
3) Added : php_flag output_buffering on to .htaccess (Although I wasn't sure if it mattered where in the .htaccess file I should put that command)
From the research I've done it appears that white space after the ?> could be the cause. Anyone know how I could tell which file would have this white space? Several of my files actually do not even have the PHP close tag. One additional note, my previous server was version 5.2.17 to 5.3.20. Any other ideas?
After checking the error logs I discovered that I was missing the mbstring PHP library, which has a function that was called by one of my theme files. Once added I was able to create and alter pages on the backend of WordPress without issue.
To all the folks who get this kind of error of page not displaying must check option.
turn on error reporting if you have commented the lines in your wp-config.php
#ini_set('display_errors','Off');
and than check for error.
if it has the error like this
PHP Warning: Cannot modify header information - headers already sent by (output started at /[server info]/wp-config.php:77)
than check your wp-config.php for extra space at top and bottom of the page.remove extra line spaces even. and than re-upload the wp-config.php.
Most of time this will solve your problem.
Happy Coding!!!!
I had a similar problem and by removing extra spaces before the "< ?php" fixed the issue. Although apparently it was a different theme functions file that was causing the issue. Make sure you look at the php file referenced in the php warning. In this example, it's 'wp-config', but it could be really anything.
PHP Warning: Cannot modify header information - headers already sent by (output started at /[server info]/wp-config.php:77)
Good luck!
Basically this issue happens because you have edited the file directly on cpanel editor or other simple text editor. Just create a new .php file and paste your post.php code in that file. Now save this file and replace this new one with old post.php.
All I want to do is be able to see a PHP file from the root without it going through the rewrites (thus our custom CMS).
Here's what I've done:
In my httpd.conf, I've commented out the call to load the mod_rewrite module.
Next, I've removed the .htaccess file from the root as it had the rewrite rules in it.
I've rebooted the server.
I've searched through phpinfo() and there are no "rewrite" strings to be found
The problem is that the server still rewrites and the request passes through our CMS.
I'm using XAMP (PHP 3.3.1, Apache 2.2.14)
What am I missing?
maybe cache problem in your browser? because a similar thing happened to me and deleting the cache solved it.
Leave it to the details... I was trying to access my_file.php on the root. However, the filename was actually my-file.php (dash vs underscore).
The page I was getting was a 404, which went through the CMS. When I access the proper file, the one with the dash, I get what I'm supposed to.
I appologize for the waste of time :)
I'm on a VPS environment so I have root access, btw.
So take a look at these issues:
http://www.sonikastudios.com/wp-content/themes/sonikas/scripts/timthumb.php?src=/wp-content/uploads/tedleescreenshot1.jpg&w=100&h=100&zc=1&q=100
That returns a 404 error.
However when I move timthumb.php to the root of the site, it works.
I verified file/folder permissions, it's not the issue. Also, another PHP generated image that i use for Captcha, is doing the same thing...
So essentially it boils down to no .php files running from within folders. However this is not an issue otherwise because PHP scripts I have under /admin/ on other sites work fine.
So... what could cause this? Most forum articles I read lean towards a mod_security problem, but I don't even know where to start, as I'm not an apache expert.
As you have root access, try looking for what is happening in Apache logs. To follow latest request you can use tail.
Which version of Apache you are running? In my configuration of Apache 2.2 you can follow error log in terminal by invoking:
tail -f /var/log/httpd/error_log
It seems that default configuration of Apache 2.2 has error log in /usr/local/apache2/logs/error_log, so my configuration is not default.
If you do not have success with error log, try also looking for information in access log, default location at /usr/local/apache2/logs/access_log.
Same error can occur when the file it self is also writable. Make sure the file is 644 and NOT 666 !
Wordpress is probably using some mod_rewrite rules to send every request to its index.php. And there it’s analyzing the request and returning a 404 status code if one of its internals was requested.
This is a problem with your .htaccess file generated by WordPress. It redirects all requests for your site that aren't wp-admin/ or in your uploads directory to the index.php file for WordPress (the request handler that queries for posts, etc.)
In my case, the following PERMISSION changes solved the (Timthumb.php) issue:
The PHP script must be "644".
All of the parent directories must be "755"; Neither "775" nor "777".