我目前有以下代码来重写搜索引擎友好的网址到PHP可以处理的东西,但有几个问题。PHP的高级Htaccess重写规则
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*)/(.*) index.php?$1/$2
这改写domain.com/cat/mens/size/large/
到domain.com/index.php?cat/mens/size/large/
。
这将是理想的,如果我可以把它改写为这样的事情用不同量的子目录,如这是友好的PHP代码:
理想重写:domain.com/index.php?cat=mens&size=large
另一个例如:domain.com/page/value/subpage/subvalue/something/true/
应该改写为:domain.com/index.php?page=value&subpage=subvalue&something=true
也就是有没有办法改写:domain.com/search/?q=blah+blah
为:domain.com/index.php?search&q=blah+blah
是的,这是我现在正在做的,只是用斜杠爆炸字符串。所以举个例子,如果我想修改重写来处理这个问题: ** domain.com/cat/mens/size/large /?q = blah + blah&abc = 123 ** 我该怎么做? 谢谢! :-) – Matt 2010-02-23 12:36:51
用.htaccess或用php处理字符串? – PawelMysior 2010-02-23 14:10:13
使用.htaccess是因为它目前没有在重写中传递字符串的那部分,所以PHP不会看到最后一个斜杠后的任何内容。 – Matt 2010-02-23 15:49:51