【发布时间】:2016-04-23 11:33:04
【问题描述】:
您好,我已经创建了干净的网址 但我希望这个干净的网址获得动态网址
例子
http://localhost:8081/olshop/products/filters/?weight=1&category=shrit
如果超过 10 个数据则使用分页
http://localhost:8081/olshop/products/filters/?weight=1&category=shrit/1
或者用户可以只过滤权重或只过滤类别或两者兼而有之
例子
http://localhost:8081/olshop/products/filters/?category=shrit
使用分页
http://localhost:8081/olshop/products/filters/?category=shrit/1
如何在 .htaccess 文件中像这样处理干净的 url?
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule index$ index.php [L]
RewriteRule ^products/(\d+)$ index.php?p=products&page=$1 [L]
RewriteRule ^products/filters/([^/]+)/?$ index.php?p=products&weight=$1 [L]
RewriteRule ^products/filters/(.*)\/(\d+)$ index.php?p=products&weight=$1&page=$2 [L]
RewriteRule ^([^/.]+)/?$ index.php?p=$1 [QSA,L]
ErrorDocument 404 /404.html
</IfModule>
我已经尝试过这样的链接
http://localhost:8081/olshop/products/filters/?weight=1&category=shrit
此结果 404 未找到
帮帮我谢谢
【问题讨论】:
-
你能包括你到目前为止所尝试的吗?
-
是的,我已经尝试过这样的链接localhost:8081/olshop/products/filters/… 找不到结果
-
@devpro this post this link like movie.php?movie=name in my link like this index.php?p=products&weight=1&category=shirts will be result localhost:8081/olshop/products/filters/…
-
为什么要在参数后面加上寻呼机/1?你不能改用这种网址吗:
http://localhost:8081/olshop/products/filters/1/?weight=1&category=shrit?