Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.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
如何使用.htaccess向php代码传递第二个参数?_Php_Json_.htaccess_Url Rewriting_Url Redirection - Fatal编程技术网

如何使用.htaccess向php代码传递第二个参数?

如何使用.htaccess向php代码传递第二个参数?,php,json,.htaccess,url-rewriting,url-redirection,Php,Json,.htaccess,Url Rewriting,Url Redirection,我正在使用友好的URL和.htaccess编写api来执行重定向 当我需要传递第二个参数时,我遇到了问题 我的.htaccess文件如下所示: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php RewriteRule ^mesas\/?([0-9]+)\/?(.+)\/?$ mesas.php?status=

我正在使用友好的URL和.htaccess编写api来执行重定向

当我需要传递第二个参数时,我遇到了问题

我的.htaccess文件如下所示:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

RewriteRule ^mesas\/?([0-9]+)\/?(.+)\/?$ mesas.php?status=$1
RewriteRule ^statusmesa\/?([0-9]+)\/?(.+)\/?$ statusmesa.php?idmesa=$1&status=$2
当我使用
statusmesa/2/3
调用statusmesa时,它作为第一个参数
2
返回,作为第二个参数
3.php/2/3

我的规则怎么了

请注意,文件.htaccss具有多条路由的多条规则

问题已解决

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)/$  /$1 [L,QSA]

RewriteRule ^mesas\/?([0-9]*)?$ mesas.php?status=$1
RewriteRule ^statusmesa/([0-9-]+)/([0-9]+)/?$ statusmesa.php?idmesa=$1&status=$2 [NC]

它们都应该在PHP文件的
$\u GET
数组中。不,第一个和第二个参数使用$\u GET to$var,我不使用数组。如果您调用
statusmesa/2/3
,那么从哪里附加了
3.PHP
进行重写?此外,您的规则没有停止处理规则集的
[L]
标志,例如:
重写规则^statusmesa\/?([0-9]+)\/?(.+)\/?$statusmesa.php?idmesa=$1&status=$2[L]