繁体   English   中英

htaccess seo url友好,带有\\和/

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM