如何使用这样的mod_rewrite?

时间:2014-05-07 15:49:28

标签: php .htaccess mod-rewrite

如何重写网址我喜欢这个

/details.php?pid={id}
exam: /details.php?pid={ee76f41017c6f6aa762a2bfb7def83c5}

我想要

/products/{id}/name

我试试这个

RewriteEngine on
RewriteCond %{QUERY_STRING}     ^cat=(.*)
RewriteRule ^details.php /products/%1? [R=301]

和这个

RewriteEngine On
RewriteRule ^products/([^/]*)$ /details.php?pid=$1 [L]

1 个答案:

答案 0 :(得分:0)

这应该有效:

RewriteEngine on

RewriteCond %{THE_REQUEST} ^(GET|POST)\ /details\.php\?pid=(.*)\ HTTP
RewriteRule ^ /products/%2/name? [R=301,L]

以上内容会将details.php?pid={id}更改为products/{id}/name