表单提交后重写动态URL

时间:2015-07-12 16:39:14

标签: php .htaccess mod-rewrite

我的链接是

 document.querySelector('li#field_2_31 label').innerHTML = 'New label';

我已经使用htaccess删除了.php,一切都在用户搜索时分开,第一页将显示上面的链接,我想显示如下链接:

search?c=category&s=product

我尝试了以下代码:

search/category/product

上面我错过了什么?

1 个答案:

答案 0 :(得分:1)

以这种方式制定规则:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /site/

RewriteCond %{THE_REQUEST} /search\?c=([^&\s]+)&s=([^&\s]+) [NC]
RewriteRule ^ search/%1/%2? [L,R]

RewriteRule ^product/([^/]+)/([^/]+)/([^/]+)/?$ product.php?id=$1&c=$2&name=$3 [L,QSA]

RewriteRule ^search/([^/]+)/([^/]+)/([^/]+)/?$ search.php?c=$1&s=$2&page=$3 [L,QSA]

RewriteRule ^search/([^/]+)/([^/]+)/?$ search.php?c=$1&s=$2 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php [L]