Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.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
htaccessphp无法工作_Php_.htaccess - Fatal编程技术网

htaccessphp无法工作

htaccessphp无法工作,php,.htaccess,Php,.htaccess,我的.htaccess无法与GET一起使用。它显示“news/”,但一旦我转到“news/1”或“news/1/”它就不工作了 Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule ^/?$ index.php [NC,L] RewriteRule ^news/$ news.php RewriteRule ^news$ news.php RewriteRule ^news/([a-zA-Z0-9_-]

我的.htaccess无法与GET一起使用。它显示“news/”,但一旦我转到“news/1”或“news/1/”它就不工作了

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteRule ^/?$    index.php    [NC,L]

RewriteRule ^news/$ news.php
RewriteRule ^news$ news.php
RewriteRule ^news/([a-zA-Z0-9_-]+)/$ news.php?id=$1 [L,QSA]
RewriteRule ^news/([a-zA-Z0-9_-]+)$ news.php?id=$1 [L,QSA]
我的PHP是:

if(!isset($_GET["id"])){
$Article->printArticles();
}else{
$Article->printArticle($_GET["id"]);
}
但是它找不到
$\u GET[“id”]
,但是在localhost上它可以工作。 已尝试使用[L,QSA]、[N]、[NC,L]和不使用任何这些

htaccess如何查找
$\u GET[“id”]

htaccess如何查找
$\u GET[“id”]

这很可能是web服务器上启用了
多视图
选项的结果

使用顶部的此行将其关闭:

Options +FollowSymLinks -MultiViews
Apache的内容协商模块
使用,该模块在
mod_rewrite
之前运行,并使Apache服务器匹配文件扩展名。因此,如果
/news
是URL,那么Apache将提供
/news.php