关于mod_rewrite htaccess clean URL参数

时间:2015-07-31 01:58:44

标签: php .htaccess mod-rewrite url-rewriting clean-urls

我的网址:private boolean isPackageInstalled(String packagename, Context context) { PackageManager pm = context.getPackageManager(); try { pm.getPackageInfo(packagename, PackageManager.GET_ACTIVITIES); return true; } catch (NameNotFoundException e) { return false; } }

它应该是: www.example.com/index.php?fruit=banana&color=yellow&amount=2 ----->成功

那么为什么呢: www.example.com/banana/yellow/2 -----> ERROR

htaccess的:

www.example.com/banana/2

1 个答案:

答案 0 :(得分:0)

试试这个:

RewriteEngine On
RewriteRule ^/?([^/]+)/([^/]+)/([^/]+)/?$ ./index.php?fruit=$1&color=$2&amount=$3 [QSA,NC,L]

RewriteRule ^/?([^/]+)/([^/]+)/?$ ./index.php?fruit=$1&amount=$2 [QSA,NC,L]