目前,我有这在我的.htaccess文件:
RewriteEngine叙述上
的RewriteBase /
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-l
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^( w +)(/( w +))/ $ route.php 1 = $ 1安培;???2 = $ 3 [L]
所以我可以做 myurl.com/foo/bar(/)
或只是 myurl.com/foo(/)
(可选尾随斜线,稳赚不赔)
我不是很熟悉规则前pression,所以我怎么会有这种允许高达约6个参数(myurl.com/one/two/three/four/five/为6个)
?
重写规则^( w +)(?:/( w +))?(?:/( w +) ):)(:/( w +?))?(/( w +?)?(?:/( w +)???)/ $ route.php 1 = $ 1和2 2 = $和3 = $ 3及4 = $ 4和5 = $ 5和6 = $ 6 [L]
您可以检查一下
要允许在参数空间中,你可以使用:
重写规则^([ w ] +)(?:/([ w ] +))?(?:/([ w ] +))? (?:/([ w ] +))?(?:/([ w ] +))????(?:/([ w ] +))/ $ route.php 1 = $ 1和2 2 = $和3 = $ 3和4 = $ 4和5 = $ 5和6 = $ 6 [L]
I currently have this in my .htaccess file:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(w+)(/(w+))?/?$ route.php?1=$1&2=$3 [L]
So I can do myurl.com/foo/bar(/)
or just myurl.com/foo(/)
(optional trailing slash, can't lose)
I'm not very familiar with regular expression, so how would I have this allow up to around 6 parameters (myurl.com/one/two/three/four/five/six)
?
RewriteRule ^(w+)(?:/(w+))?(?:/(w+))?(?:/(w+))?(?:/(w+))?(?:/(w+))?/?$ route.php?1=$1&2=$2&3=$3&4=$4&5=$5&6=$6 [L]
You can check it here
To allow spaces in the parameters you can use:
RewriteRule ^([w ]+)(?:/([w ]+))?(?:/([w ]+))?(?:/([w ]+))?(?:/([w ]+))?(?:/([w ]+))?/?$ route.php?1=$1&2=$2&3=$3&4=$4&5=$5&6=$6 [L]
上一篇:阿帕奇重写preserve查询字符串重写、字符串、阿帕奇、preserve
下一篇:ErrorDocument的404 /404.php不工作在PHP .htaccess文件文件、工作、ErrorDocument、htaccess