Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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 无法通过.htaccess获取url字符串中的第10个变量_Php_.htaccess - Fatal编程技术网

Php 无法通过.htaccess获取url字符串中的第10个变量

Php 无法通过.htaccess获取url字符串中的第10个变量,php,.htaccess,Php,.htaccess,我想在我的php代码中得到get sort_by,但它似乎是返回数字为0的变量1的值 RewriteRule ^abc/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ search.php?counrty=abc&state=$1&gender=$2&r_city=$3&r_mstatus=$4&r_religion=$5&r_et

我想在我的php代码中得到get sort_by,但它似乎是返回数字为0的变量1的值

RewriteRule ^abc/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ search.php?counrty=abc&state=$1&gender=$2&r_city=$3&r_mstatus=$4&r_religion=$5&r_ethnicity=$6&r_cast=$7&r_profession=$8&r_education=$9&sort_by=$10 [NC]

根据Apache文档,对于
$N
N
的值只能是0-9。因此,试图获得10美元是行不通的。您可能需要经历两个重写步骤。所以,也许你会用这样的方式:

RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+/[^/]+/[^/]+)/?$ search.php?country=$1&state=$2&gender=$3&r_city=$4&r_mstatus=$5&r_religion=$6&r_ethnicity=$7&r_cast=$8&r_profession=$8&profession_and_education_and_sort=$9 [NC]

RewriteCond %{REQUEST_FILENAME} ^search\.php$
RewriteCond %{QUERY_STRING} ^(country=.*&state=.*&gender=.*&r_city=.*&r_mstatus=.*&r_religion=.*&r_ethnicity=.*&r_cast=.*)&profession_and_education_and_sort=([^/]+)/([^/]+)/([^/]+)
RewriteCond ^search\.php$ search.php?%1&r_profession=%2&r_education=%3&sort_by=%4 [NC,L]

您是否正确获取了其他9个参数?是的,我正确获取了所有其他参数,除了排序依据的第10个参数。通过将abc替换为国家名称,我获得了500个内部服务器错误。您能给我推荐其他参数吗。或者我犯了什么错误?对不起,我没有看到“abc”本身就是一种替代品。我已经更新了我的答案。我得到了当前问题的解决方案。虽然它不是完美的,但这适合我目前的情况。在这里,我使用explode($\u GET)来获取我的最后一个值,因为这个值是以字符串形式出现的。