模式重写添加另一个URL参数,但不工作(多参数)

问题描述:

我有以下htaccess文件$ C $以下

I have the following htaccess file code below

RewriteEngine On
RewriteBase /site/public/admin/

RewriteCond %{REQUEST_METHOD} POST
RewriteRule ^ - [L]

RewriteCond %{THE_REQUEST} \s([^.]+?)(?:\.php)?\?caseid=([^&\s]+) [NC]
RewriteRule ^ %1/caseid/%2/? [R=302,L]

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

## hide .php extension snippet    
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1/ [R=302,L]

# add a trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=301]

# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

这工作完全正常,只要我提供1个参数是 caseid

This works perfectly fine as long as I provide 1 parameter which is caseid i.e

http://localhost/site/public/admin/PIClaimant.php?caseid=11

以上网址成功地转变为

The URL above successfully changes to

http://localhost/site/public/admin/PIClaimant/caseid/11/

我有几页有两个参数,即 PIClaimant.php caseid = 11&安培; picid = 34 。起初,当我创建htaccess文件我没注意这些网页(安培; picid = 34只被用在了几页4或5最大)。现在,当我回到那些网页里面有这些参数,他们没有工作没有显示网页的内容。他们的工作,直到第一个参数 PIClaimant / caseid / 11 / 但与第二个参数。

I've had a few pages with two parameters, which are PIClaimant.php?caseid=11&picid=34. Initially when I was creating htaccess file I did not pay attention to those pages (&picid=34 only being used at a few pages 4 or 5 max). Now when I go back to those pages which has those parameters, they are not working not showing the content of page. They work till first parameter PIClaimant/caseid/11/ but not with the second parameter.

由于我不是很擅长这个(模式重写),我需要你的帮助。

Since I am not very good at this (mode rewriting) I need your help.

任何想法?

事情变得更加复杂,现在:)

Things are getting more complicated now :)

试试这个code在你的.htaccess:

Try this code in your .htaccess:

RewriteEngine On
RewriteBase /site/public/admin/

RewriteCond %{REQUEST_METHOD} POST
RewriteRule ^ - [L]

RewriteCond %{THE_REQUEST} \s([^.]+?)(?:\.php)?\?caseid=([^&\s]+)?\&picid=([^&\s]+)\s [NC]
RewriteRule ^ %1/caseid/%2/picid/%3/? [R=302,L,NE]

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

RewriteCond %{THE_REQUEST} \s([^.]+?)(?:\.php)?\?caseid=([^&\s]+)\s [NC]
RewriteRule ^ %1/caseid/%2/? [R=302,L,NE]

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

## hide .php extension snippet    
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} \s([^.]+)\.php [NC]
RewriteRule ^ %1/ [R=302,L,NE]

# add a trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=301,NE]

# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]