原始网址:hall/booking.php?hall_ id=1&;booking_date=2014-10-23


Original url: hall/booking.php?hall_id=1&booking_date=2014-10-23&session=Morning I want: hall/booking/1/2014-10-23/Morning

我的项目中有一个url,比如

hall/description_banquethall.php?hall_id=1,我的url像hall/description_banquethall/1 一样工作

通过使用.htaccess代码

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /hall
## don't touch /forum URIs
RewriteRule ^forums/ - [L,NC]
## hide .php extension snippet
# To externally redirect /dir/foo.php?id=123 to /dir/foo
RewriteCond %{THE_REQUEST} ^GET's([^.]+)'.php'?hall_id=([^&'s]+) [NC]
RewriteRule ^ %1/%2/? [R,L]
# To internally forward /dir/foo/12 to /dir/foo.php?id=12
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/([^/]+)/?$ $1.php?hall_id=$2 [L,QSA]
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^GET's([^.]+)'.php's [NC]
RewriteRule ^ %1 [R,L]
# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*?)/?$ $1.php [L]

现在我想重定向我的另一个url hall/booking.php?hall_ id=1&booking_date=2014-10-23&session=上午到大厅/预订/2014-10-23/上午

## hide .php extension snippet行下面添加以下两个新规则:

RewriteCond %{THE_REQUEST} ^GET's([^.]+)'.php'?hall_id=([^&'s]+)&booking_date=([^&'s]+)&session=([^&'s]+) [NC]
RewriteRule ^ %1/%2/%3/%4? [R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/([^/]+)/([^/]+)/([^/]+)/?$ $1.php?hall_id=$2&booking_date=$3&session=$4 [L,QSA]