我的项目中有两个网址,我尝试使用mod_rewrite
进行翻译:
hall/booking_message.php?booking_id=11
> hall/booking_message/11
hall/venues.php?city=delhi&city_value=1&locality=mehrauli&locality_value=82
> hall/venues/city/delhi/city_value/1/locality/mehrauli/82
到目前为止,我在.htaccess
中有以下内容适用于hall/booking.php?hall_id=5&booking_date=2014-10-23&session=Morning
和hall/description_banquethall.php?hall_id=5
,但不是上面列出的两个网址:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /hall/
## don't touch /forum URIs
RewriteRule ^forums/ - [L,NC]
## hide .php extension snippet
RewriteCond %{THE_REQUEST} ^GET\s([^.]+)\.php\?city=([^&\s]+)&city_value=([^&\s]+)&locality=([^&\s]+)&locality_value=([^&\s]+) [NC]
RewriteRule ^ %1/%2/%3/%4/%5? [R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ $1.php?city=$2&city_value=$3&locality=$4&locality_value=$5 [L,QSA]
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]
# 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?id=123 to /dir/foo
RewriteCond %{THE_REQUEST} ^GET\s([^.]+)\.php\?booking_id=([^&\s]+) [NC]
RewriteRule ^ %1/%2/? [R,L]
# To internally forward /dir/foo/12 to /dir/foo.php?booking_id=12
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/([^/]+)/?$ $1.php?booking_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]
答案 0 :(得分:0)
将此链接放入.htaccess,然后检查您的链接大厅/ booking_message / 11
RewriteRule ^(.*)/([.*]+)/([.*]+)/?$ $1.php?booking_message=$2&booking_id=$3 [L,QSA]