我有以下网址
http://localhost/mybb/index.php?url=widgetboard/questions&step=1&id=1
在应用重写规则
后变为以下URLhttp://localhost/mybb/widgetboard/questions/step/1/id/1
是否可以删除2个单词,即" step"和" id"从网址开始,在网址的最后添加.html
我的代码是
Options -MultiViews
# turn rewriting on
RewriteEngine On
# When using the script within a sub-folder, put this path here, like /mysubfolder/
# If your app is in the root of your web folder, then please delete this line or comment it out
RewriteBase /mybb/
RewriteRule ^(.+?)/(step)/([0-9]+)/(id)/([0-9]+)/?$ index.php?url=$1&$2=$3&$4=$5 [NC,L,QSA]
RewriteRule ^(.+?)/(category)/([0-9]+)/(answer)/([0-9]+)/?$ index.php?url=$1&$2=$3&$4=$5 [NC,L,QSA]
RewriteRule ^(.+?)/(step)/([0-9]+)/?$ index.php?url=$1&$2=$3 [NC,L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+?)/?$ index.php?url=$1&$2=$3 [NC,L,QSA]
答案 0 :(得分:1)
您可以在RewriteBase /mybb/
行下面插入此规则:
RewriteRule ^([^/]+)/([^/]+)/([0-9]+)/([0-9]+)/?$ index.php?url=$1/$2&step=$3&id=$4 [L,QSA]
答案 1 :(得分:0)
将您的第二条规则更改为:
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?step=$1&id=$2 [NC,L,QSA]
然后,如果用户点击此网址:domain.com/3/120
,您的PHP脚本将会收到index.php?step=3&id=120