【发布时间】:2015-07-23 20:27:17
【问题描述】:
我所有的重写都没有一个。当用户搜索时,我希望 URL 在 url 栏中正确显示。
Options +FollowSymLinks
RewriteEngine on
RewriteBase /website/
RewriteCond %{THE_REQUEST} /search\?c=([^&\s]+)&s=([^&\s]+)&mincost=([^&\s]+)&maxcost=([^&\s]+)&sort_by=([^&\s]+)&colour=([^&\s]+) [NC]
RewriteRule ^search/%1/%2/%3/%4/%5/%6? [L,R]
RewriteRule ^product/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ product.php?id=$1&c=$2&name=$3&page=$4 [L,QSA]
RewriteRule ^product/([^/]+)/([^/]+)/([^/]+)/?$ product.php?id=$1&c=$2&name=$3 [L,QSA]
RewriteRule ^search/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ search.php?c=$1&s=$2&mincost=$3&maxcost=$4&sort_by=$5&colour=$6&page=$7 [L,QSA]
RewriteRule ^search/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ search.php?c=$1&s=$2&mincost=$3&maxcost=$4&sort_by=$5&colour=$6 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]
/website/search/category/all/100/500/low-to-high/any-color
(进入网址栏时有效)
/website/search?c=category&s=all&mincost=100&maxcost=500&sort_by=low-to-high&colour=any-color
(在使用过滤器和提交表单时显示)- 我需要这个 url 显示为:
/website/search/category/all/100/500/low-to-high/any-color
【问题讨论】:
-
搜索
form action="/website/search"
标签: php .htaccess mod-rewrite