Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
由于升级到PHP 5.6,.htaccess重写循环而导致500服务器错误?_Php_Apache_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

由于升级到PHP 5.6,.htaccess重写循环而导致500服务器错误?

由于升级到PHP 5.6,.htaccess重写循环而导致500服务器错误?,php,apache,.htaccess,mod-rewrite,url-rewriting,Php,Apache,.htaccess,Mod Rewrite,Url Rewriting,我已经将PHP从5.5升级到了5.6,突然之间,我的使用url重写的网站出现了500个服务器错误。我和webhost谈过,他们说我的.htaccess导致重写循环。不过这很奇怪,因为我有相同的.htaccess文件,而且它从未改变过。下面是我的.htaccess文件中的代码,有人知道我哪里弄错了吗 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond

我已经将PHP从5.5升级到了5.6,突然之间,我的使用url重写的网站出现了500个服务器错误。我和webhost谈过,他们说我的.htaccess导致重写循环。不过这很奇怪,因为我有相同的.htaccess文件,而且它从未改变过。下面是我的.htaccess文件中的代码,有人知道我哪里弄错了吗

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} !\.(js|css|gif|jpg|png|ico)$ [NC]
RewriteRule ^(.*)$ index.php [QSA,L]
RewriteRule ^get/([0-9]+).gif$ /click/siggy/$1 [L]

我认为以下规则在服务器上导致无限循环/500错误,因为目标路径正在重写为自身:

RewriteCond %{REQUEST_URI} !\.(js|css|gif|jpg|png|ico)$ [NC]
RewriteRule ^(.*)$ /index.php [L]
上述规则排除了js、css、gif..,并将任何其他文件重写为/index.php,包括/index.php=>/index.php。 为了解决这个问题, 必须使用负重写条件排除目标路径/index.php:

 RewriteCond %{REQUEST_URI} !/index\.php$
RewriteCond %{REQUEST_URI} !\.(js|css|gif|jpg|png|ico)$ [NC]
RewriteRule ^(.*)$ index.php [QSA,L]