Problems with .htaccess after upgrading to PHP 5.4

非 Y 不嫁゛ 提交于 2019-12-12 02:44:53

问题


I have had some difficulties with my site after updating my servers to use PHP version 5.4.. I have been through a lot of support tickets and browsed the internet for 2 days.. Now I need to ask directly to the people who actually know about it.

After updating the php version I started to get a 500 error on my pages and it turned out that my rewrite rules in my htaccess file wasn't working anylonger. They did in php version 5.2 but not in 5.4.

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /

# If the request is for a valid directory
RewriteCond %{REQUEST_FILENAME} -d [OR]
# If the request is for a valid file
RewriteCond %{REQUEST_FILENAME} -f [OR]
# If the request is for a valid link
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^ - [L]

# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} \s/+website\.php\?id=([^\s&]+) [NC]
RewriteRule ^ %1? [R=302,L]

RewriteRule ^([\w.-]+)/?$ website.php?id=$1 [L,QSA]

RewriteRule ^([\w.-]+)/([\w.-]+)/?$ website.php?id=$1&page=$2 [L,QSA]

</IfModule>

Can anybody tell me what I have to do differently? I would really appreciate it.

EDIT:

I got this copy from my livechat with hostgator:

[Thu Jun 26 03:54:07 2014] [error] [client ] malformed header from script. Bad header=<br />: website.php
[Thu Jun 26 03:55:35 2014] [error] [client ] Cannot load the ionCube PHP Loader - it was built with configuration 2.2.0, whereas running engine is API220100525,NTS
[Thu Jun 26 03:55:35 2014] [error] [client ] The Zend Engine API version 220100525 which is installed, is newer.
[Thu Jun 26 03:55:35 2014] [error] [client ] Contact Zend Technologies at http://www.zend.com/ for a later version of Zend Optimizer.
[Thu Jun 26 03:55:35 2014] [error] [client ]

回答1:


Try adding this line:

zend_extension = /usr/local/ioncube/ioncube_loader_lin_5.4.so

to your php.ini




回答2:


SOLUTION IS NOW FOUND

I made the wrong assumption to think it was due to my rewrite rule. The problem seemed to be at HostGator. If you host at HostGator, this will be helpful for you. The reason all this started was because HostGator has announced, that the will upgrade the servers to run PHP 5.4 as standard instead of PHP 5.2. What they didn't mention, was the structure of their servers and how individual sites has to manage their individual PHP files.

Well I found out that by changing the name of my php.ini file in the root directory (making it invalid for the server to use), the system located a PHP version specific php.ini file in the main servers directory. This made me realize that the php.ini file in my root directory had to be changed completely, so therefor I created a new php.ini file containing the 5.4 version. The site didn't change, because the files were basically identical, but it made it possible for me to use the EZConfig in cPanel again.

This is what to do:

  1. Change PHP version either in the PHP configuration tab in cPanel, or by adding AddHandler application/x-httpd-php54 .php to your .htaccess file.
  2. Open File Manager in cPanel.
  3. Locate your root folder (Home) and find the php.ini file.
  4. If you want to keep your existing php.ini file as a backup, rename it to ex. php_old.ini.
  5. Create a new file named php.ini and insert the content from following link: https://wiki.cac.washington.edu/display/webpub/php.ini+for+PHP+5.4

Good luck with it. Hope this will solve it for somebody as well, so that they don't have to spend 3 days solving it themselves.



来源:https://stackoverflow.com/questions/24426690/problems-with-htaccess-after-upgrading-to-php-5-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!