我有这个网址,该网址是从应该在数据库内部搜索事件的表单生成的:http://localhost:8080/search?event=ecddf4
我希望以这种方式重写网址:http://localhost:8080/search/event/ecddf4
我正在使用FastRoute作为我的php路由系统,但是我想尝试一些更文档化的内容,例如Simple Router
。我的.htaccess
文件中包含以下规则:
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-l
RewriteRule ^(.*)$ index.php/$1
我在两个路由系统中都使用了这套规则,但是提交表单时我无法获得漂亮的URL。谁能解释我该如何实现?这是我使用FastRoute的几次,明天我将从php-simple-router开始。有人建议我使用regexp映射url,但是如何?我已经阅读了文档,但是不清楚我是否需要设置像/search/{event}
这样的占位符来重写url?
这是我必须提交搜索的表格:
<form method="GET" action="search" name="">
<input type="search" name="event" />
<button type="submit">Search</button>
</form>