Php htaccess使用查询字符串中断重写url

Php htaccess使用查询字符串中断重写url,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,所以我试着从http://project2.local/camera?camera_id=1至http://project2.local/camera/1中的.htaccess。。。现在,每次我添加.htaccess行时: Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] # Here we rewrite the

所以我试着从
http://project2.local/camera?camera_id=1
http://project2.local/camera/1
中的
.htaccess
。。。现在,每次我添加.htaccess行时:

Options +FollowSymlinks

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

# Here we rewrite the camera link
# RewriteRule ^camera/([^/]*)$ /camera?camera_id=$1 [L]


# RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /camera\.php\?camera_id=([^\&\ ]+)
# RewriteRule ^/?camera\.php$ /camera/%1? [L,R=301]

# specific rule
RewriteCond %{QUERY_STRING} ^([^=]+)=([^&]+)
RewriteRule ^(camera)$ /camera.php?camera_id=$1 [L]
我得到了错误
注意:未定义索引:camera\u id
。现在我只是尝试获取查询字符串,但它不起作用,就像从不


是什么导致此问题?

您可以使用此htaccess

RewriteEngine on

#redirect and rewrite url from http://project2.local/camera?camera_id=1 to http://project2.local/camera/1
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /camera\.php\?camera_id=([^\&\s]+)
RewriteRule ^/?camera\.php$ /camera/%1? [L,R=301]
RewriteRule ^camera/([^/]*)$ /camera.php?camera_id=$1 [L]
#remove. php extension
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^\.]+)/?$ $1.php [NC,L]

返回相同的问题。在线
4
,其代码如下:
$camera\u id=$\u GET[“camera\u id”]
好的,如果uri
/camera/1
将您带到
/camera.php
,这意味着重写规则是可以的。问题可能出在您的php脚本中。请尝试在htaccess
选项-多视图
的顶部添加这一行。这会产生相同的结果,如果我在
$\u GET
上执行var\u转储,它将返回一个空数组?htaccess中是否有其他规则?