简体   繁体   中英

Htaccess with multiple rewrite rules

I have a problem with my rewrite rule in htaccess file. 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.

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:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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