Rewriterule结束斜线

时间:2010-05-27 15:18:47

标签: url mod-rewrite

我正在使用Rewriterule以获得以下网址:http://www.myhost.com/var1/var2/

RewriteRule ^(.*)\/(.*)\/$  index.php?var1=$1&var2=$2 [L]

我想补充的是,当有人输入myhost.com/var1/var2(没有结束斜杠)时,它仍会转到同一页面。

有没有比这更好的方法?

RewriteRule ^(.*)\/(.*)\/$  index.php?var1=$1&var2=$2 [L]
RewriteRule ^(.*)\/(.*)$  index.php?var1=$1&var2=$2 [L]

1 个答案:

答案 0 :(得分:0)

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\/]*)\/([^\/]*)\/?$  index.php?band=$1&song=$2 [L]

注意结尾?