升级到PHP 5.4后.htaccess的问题 [英] Problems with .htaccess after upgrading to PHP 5.4

查看:243
本文介绍了升级到PHP 5.4后.htaccess的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将服务器更新为使用PHP 5.4版后,我在网站上遇到了一些麻烦。.我已经获得了很多支持通知,并且浏览了Internet 2天。.现在,我需要直接询问那些

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.

更新了php版本后,我的页面上开始出现500错误,结果证明我的htaccess文件中的重写规则不是工作了。他们在php版本5.2中做了,但在5.4版本中没有。

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.

编辑:

我从我与hostgator进行的实时聊天:

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 ]


推荐答案

现在可以找到解决方案

我做出了错误的假设,认为这是由于我的重写规则造成的。问题似乎出在HostGator。如果您托管在HostGator,这将对您有所帮助。所有这些开始的原因是因为HostGator宣布,它将升级服务器以将PHP 5.4作为标准运行而不是PHP 5.2。他们没有提到的是服务器的结构以及各个站点​​如何管理各自的PHP文件。

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.

好吧,我发现通过更改名称我在根目录中的 php.ini 文件(使服务器无法使用),系统在主服务器目录中找到了特定于PHP版本的php.ini文件。这使我意识到必须完全更改根目录中的php.ini文件,因此我创建了一个新的 php.ini 文件,其中包含5.4版本。站点没有更改,因为文件基本相同,但是这使我可以再次在cPanel中使用EZConfig。

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.

这是要执行的操作:


  1. 在cPanel的PHP配置选项卡中更改PHP版本,或者通过添加 AddHandler application / x-httpd-php54 .php
    .htaccess 文件。

  2. 打开文件管理器在cPanel中。

  3. 找到您的根文件夹(主页)并找到 php.ini 文件。

  4. 如果要保留现有的 php.ini 文件作为备份,请将其重命名为ex。 php_old.ini

  5. 创建一个名为 php.ini 的新文件,然后通过以下链接插入内容: https:// wiki。 cac.washington.edu/display/webpub/php.ini+for+PHP+5.4

  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

祝你好运。希望这也能为别人解决,这样他们就不必花3天的时间自己解决问题。

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.

这篇关于升级到PHP 5.4后.htaccess的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆