【发布时间】:2011-08-04 17:38:09
【问题描述】:
假设我在用户浏览页面 (www.date.com) 上有如下 URL: www.date.com/Location-A/Education-B/Sex-C/Interest-D/
情况是用户只能浏览所有 (4) 个可用条件中的一个数(1 或 2) www.date.com/Education-B/ 或 www.date.com/Sex-C/Interest-E/
还假设 URL 中浏览条件的顺序很重要(即 A/B - ok,但 B/A 不行)
我的.htaccess 文件中有代码
重写引擎开启
1 变量案例
RewriteRule ^/Location-([^/]+)/$ /index.php?Location=$1 [L]
RewriteRule ^/Education-([^/]+)/$ /index.php?Education=$1 [L]
(...)
2个变量案例
(...)
4个变量案例
RewriteRule ^/Location-([^/]+)/Education-([^/]+)/Sex-([^/]+)/Interest-([^/]+)/$ /index.php?Location=$1&Education=$2&Sex=$3&Interest=$4 [L]
如果我有 8 个变量,这会变得非常长。
有没有更聪明的方法来实现上述目标?可能使用 [C] - 链或 [N] - 下一个? (URL 变量的顺序很重要)
提前致谢
【问题讨论】:
标签: php .htaccess friendly-url