简体   繁体   中英

.htaccess RewriteRule issue, some rules not working

I have an large .htaccess file with some rules. One of those rules is not working and I don't know why.

The file have I checked with: http://www.htaccesscheck.com and there are no issues.

I have 2 links in my php file:

echo '<a href="corten-stalen-borderrand-hoek-type-'.$_GET['type'].'-03'">Bestel op maat</a>
echo '<a href="corten-stalen-borderrand-hoek-getrapt-type-'.$_GET['type'].'-04'">Bestel op maat</a>

And in my .htaccess I have:

RewriteRule ^corten-stalen-borderrand-([A-Za-z0-9-]+)-type-([A-Za-z0-9-]+)-([A-Za-z0-9-]+)$ product_borderrand_hoek.php?type=$2&id=$1&image=$3
RewriteRule ^corten-stalen-borderrand-([A-Za-z0-9-]+)-getrapt-type-([A-Za-z0-9-]+)-([A-Za-z0-9-]+)$ product_borderrand_hoek_getrapt.php?type=$2&id=$1&image=$3

The second line in the .htaccess is not working. Any suggestions?

The page where this is about: https://torza.nl/test_environment/metaalboutique/nieuwe_versie/corten-stalen-borderranden-geheel-op-maat-gemaakt?type=1&id=2

The image below with the geen box is working OK, in the red not working ok. Should be pointing to: https://torza.nl/test_environment/metaalboutique/nieuwe_versie/product_borderrand_hoek_getrapt.php?type=1&id=hoek&image=04

I think the problem is the first rule you have presented; it also matches the second URL that should be rewritten according to the second rule, if I understand this correctly. To avoid this you have to adjust the first rule to either not include - int he first character group

RewriteRule ^corten-stalen-borderrand-([A-Za-z0-9]+)-type-([A-Za-z0-9-]+)-([A-Za-z0-9-]+)$ product_borderrand_hoek.php?type=$2&id=$1&image=$3

or, if this is not possible, prevent that getrapt shows up before type : ([A-Za-z0-9-]+)(?<!getrapt)-type

^corten-stalen-borderrand-([A-Za-z0-9-]+)(?<!getrapt)-type-([A-Za-z0-9-]+)-([A-Za-z0-9-]+)$

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