【发布时间】:2017-12-05 16:37:20
【问题描述】:
如何更改页面 url 查询并获取前两个字母。在 .htaccess 或 php 中
http://127.0.0.1/site/flowers/index.php?query=Bird
http://127.0.0.1/site/flowers/index.php?query=eagle
像这样:
http://127.0.0.1/site/flowers/search/bi/bird.html
http://127.0.0.1/site/flowers/search/ea/eagle.html
Htaccess 代码: 127.0.0.1/site/.htaccess
RewriteEngine on
RewriteRule ([^/\.]+)/?.html$ index.php?query=$1 [L]
【问题讨论】:
-
为什么
/site/中的第一个斜线后有+?你是如何获得/site/flowers/index.php?query=BirdURL 的?是通过某种形式的帖子还是href链接? -
@anubhava , 先生 .. form post /site/flowers/index.php?query=Bird ....(地址栏)
-
.htacces 位于 > ... 127.0.0.1/site/.htaccess
-
如果是表单发布,那么我建议在发布之前使用 JS 代码更改 URL。