[英]htaccess seo url friendly with \ and /
我可以在網上搜索輪胎,並且可以搜索3個參數:寬度,切片和koter(半徑)
我想在搜索后將其定向到以下URL:example.com/tires/width/sliceR/koter-> example.com/tires/205/55R/16
我從用戶那里得到的值只是數字,例如:寬度:205切片:55 koter(radius):16
我編寫這段代碼:
RewriteRule ^tires/$ /tires.php [L]
RewriteRule ^tires/([0-9/]+)/([^/]+)/([0-9/]+)$ /tires.php?width=$1&slice=$2&koter=$3 [L]
RewriteCond %{QUERY_STRING} ^width=(\w+)&slice=(\w+)&koter=(\w*)$
RewriteRule ^ http://example/tires/%1\/%2\/%3? [R,L]
但是它沒有用...並且我在上一個網址中的/時遇到了問題: http : //example.com/tires/15/15R/15/-是可以使用的http://example.com/tires/ 15 / 15R / 15-不起作用
而且,我對雙數有疑問:example.com/tires.php?width=205&slice=55&koter=17.5沒有重定向到網址友好。
謝謝你,對不起我的無知
您可以在DOCUMENT_ROOT/.htaccess
文件中使用以下代碼:
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} \s/+tires\.php\?width=([^\s&]+)&slice=([^\s&]+)&koter=([^\s&]+) [NC]
RewriteRule ^ tires/%1/%2/%3? [R=302,L,NE]
RewriteRule ^tires/$ tires.php [L]
RewriteRule ^tires/([0-9.]+)/([^/]+)/([0-9.]+)/?$ tires.php?width=$1&slice=$2&koter=$3 [L,QSA]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.