0

我需要我的网站的重写规则。

我有以下类型的 URL:

http://bag-saver.com/store/category/yellow-bags/?brand=TedBaker

但我想这样读:

http://bag-saver.com/store/category/yellow-bags-by-tedbaker/

这是我认为应该起作用的:

RewriteRule ^-(.*) ?brand=$1

(它没有)

但除此之外,该?brand参数实际上可能显示为&parameter- 例如?word=clutch&brand=TedBaker

总而言之 - 我希望将品牌参数放入静态 URL 的最后部分,前面加上“by”一词。无论品牌参数出现在 URL 字符串中的哪个位置,我都希望它能够正常工作。

这是当前的 .htaccess 文件:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /


RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

以下是需要应用的所有 URL:

http://bag-saver.com/store/category/black-bags/?brand=Jaeger
http://bag-saver.com/store/category/black-bags/?brand=Jaeger&word=Cross%20Body
http://bag-saver.com/store/category/black-bags/?word=Cross+Body&brand=Jaeger

以上需要转换为 /store/category/black-bags-by-jaeger/ 或 /store/category/black-bags-by-jaeger/?word=Cross%20Body (用于第 2 和第 3 选项)。

I also have this: http://bag-saver.com/store/search/?brand=Jaeger which needs to be converted to /store/search/bags-by-jaeger/.

4

1 回答 1

1

Try this : (if you can gives us all the variants of the url it would be better)

RewriteRule ^(.*)-by-([^/]+)/(.*)$ /$1/$3?brand=$2 [L,QSA]
于 2012-09-07T13:23:31.587 回答