Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.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 mod_rewrite-htaccess-多个参数_Php_Regex_.htaccess_Mod Rewrite - Fatal编程技术网

Php mod_rewrite-htaccess-多个参数

Php mod_rewrite-htaccess-多个参数,php,regex,.htaccess,mod-rewrite,Php,Regex,.htaccess,Mod Rewrite,我有这样一个URL: 我有一个物理文件夹文件夹,在文件夹之后的所有内容都应该是GET参数,所以我在PHP中得到这个: <?php $mode = $_GET["mode"]; // j $type = $_GET["type"]; // i $param1 = $_GET["param1"] // 123 $param2 = $_GET["param2"] // 456 我不明白,如何调用多个参数 谢谢大家! 在/folder/.htaccess中,您可以使用以下规则: Rewrite

我有这样一个URL:

我有一个物理文件夹
文件夹
,在
文件夹
之后的所有内容都应该是GET参数,所以我在PHP中得到这个:

<?php
$mode = $_GET["mode"]; // j
$type = $_GET["type"]; // i
$param1 = $_GET["param1"] // 123
$param2 = $_GET["param2"] // 456
我不明白,如何调用多个参数


谢谢大家!

/folder/.htaccess
中,您可以使用以下规则:

RewriteEngine On
RewriteBase /folder/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?mode=$1&type=$2 [L,QSA]

这将路由
https://example.com/folder/j/i?param1=123¶m2=456
https://example.com/folder/index.php?mode=j&type=i¶m1=123¶m2=456

更好的方法是使用PHP获取参数,使用“/”作为分隔符

太好了!嘿,这是不是
^([^/]+)/([^/]+)/?$
regex?是的
[^/]+
是基于否定的模式,这意味着除了
/
之外的任何东西。。。这并不像我想的那么难!非常感谢你!你能举个例子吗?
RewriteEngine On
RewriteBase /folder/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?mode=$1&type=$2 [L,QSA]