0
网址:http://localhost/url/of/the/keyword/whatever/htaccess的怪异尾随斜线问题
RewriteRule ^url/of/the/keyword/([a-z]+)/?$ ?keyword=$1 [L]
// php
echo $_GET['keyword'];
// outputs **whatever** (OK)
RewriteRule ^url/of/the/keyword/(.*)/?$ ?keyword=$1 [L]
// php
echo $_GET['keyword'];
// outputs **whatever/** (with a trailing slash, which is not expected)
任何人都可以解释为什么有第二个条件结尾的斜线?
另外,我怎样才能让百分比符号在URL重写?
http://localhost/url/of/the/keyword/%40%23%24/
RewriteRule ^url/of/the/keyword/([0-9a-zA-Z-.%])/?$ ?keyword=$1 [L]
上述规则不起作用。任何人都可以纠正这个,所以它允许一个-Z,0-9,点,连字符和百分号?
谢谢!
感谢杰森,我得到的第一个。第二,这是一个错字,我忘了加号。但即使加号,它也不起作用。结果在404. – 2011-05-21 21:44:02
我认为你的斜线需要转义。查看更新。 – 2011-05-21 23:41:54