简体   繁体   English

具有多个重写规则的 Htaccess

[英]Htaccess with multiple rewrite rules

I have a problem with my rewrite rule in htaccess file.我在 htaccess 文件中的重写规则有问题。 This is my code:这是我的代码:

#BLOCK 1#
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^([^/]+)/$ path_to_website/file.php?product=$1&country=0&pag=pag-1&rew=1 [L]
RewriteCond %{QUERY_STRING} ^(.*)=(.*)&country=0&pag=pag-1$
RewriteCond %{QUERY_STRING} !^.*rew=1.*$
RewriteRule ^.*$ /path_to_website/%2/? [R=301,L]

#BLOCK 2#
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^([^/]+)/([^/]+)/$ path_to_website/file.php?product=$1&country=$2&pag=pag-1&rew=1 [L]
RewriteCond %{QUERY_STRING} ^(.*)=(.*)&(.*)=(.*)&pag=pag-1$
RewriteCond %{QUERY_STRING} !^.*rew=1.*$
RewriteRule ^.*$ /path_to_website/%2/%4/? [R=301,L]

#BLOCK 3#
RewriteRule ^([\w-]+)/?$ path_to_website/file.php?product=$1&country=0&pag=pag-1 [L]
RewriteRule ^([\w-]+)/([\w-]+)(?!=/)$ path_to_website/file.php?product=$1&country=0&pag=$2 [L]
RewriteRule ^([\w-]+)/([\w-]+)/$ path_to_website/file.php?product=$1&country=$2&pag=pag-1 [L]
RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)$ path_to_website/file.php?product=$1&country=$2&pag=$3 [L]

The first two block comes from submit form and the third block comes from an href.前两个块来自提交表单,第三个块来自 href。

I want to add the following rules without conflict with the other rules:我想添加以下规则而不与其他规则冲突:

RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)$ path_to_website/file2.php?product=$1&country=$2&product-details=$3 [L]

edit编辑

Solved the proble, i just add another parameter to the rewrite for details-page:解决了这个问题,我只是在详细信息页面的重写中添加了另一个参数:

RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+).([\w-]+)$ path_to_website/file2.php?product=$1&country=$2&product-details=$3&place-holder=$4 [L]

Solved the problem, i just add another parameter to the rewrite for details-page:解决了这个问题,我只是在详细信息页面的重写中添加了另一个参数:

RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+).([\w-]+)$ path_to_website/file2.php?product=$1&country=$2&product-details=$3&place-holder=$4 [L]

Thanks to all:)谢谢大家:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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