如何使用.htaccess向php代码传递第二个参数?
我正在使用友好的URL和.htaccess编写api来执行重定向 当我需要传递第二个参数时,我遇到了问题 我的.htaccess文件如下所示:如何使用.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=
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]
?