【发布时间】:2012-10-12 04:37:58
【问题描述】:
我有一个搜索表单,在提交时会生成类似以下网址的内容:
http://mydomain.com/index.php?find=some+text
我的目标是让它看起来像:
http://mydomain.com/find/some+text
如何使用 .htaccess 做到这一点?
到目前为止,我有这个:
RewriteCond %{REQUEST_URI} ^/index\.php$
RewriteCond %{QUERY_STRING} &?find=(.*)&?
RewriteRule ^index.php$ find/%1? [R=301,L]
RewriteRule ^find/(.*)$ index.php?find=$1 [L]
如果查询(即我搜索的内容)仅包含数字、字母或下划线,则此方法有效,但我想让它能够搜索包括空格和其他字符在内的任何内容!
【问题讨论】:
-
这看起来可能会让你陷入循环?
标签: php .htaccess search redirect query-string