簡體   English   中英

.htaccess RewriteRule 問題,一些規則不起作用

[英].htaccess RewriteRule issue, some rules not working

我有一個帶有一些規則的大型.htaccess文件。 其中一個規則不起作用,我不知道為什么。

我檢查了該文件: http://www.htaccesscheck.com並且沒有問題。

我的php文件中有 2 個鏈接:

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>

在我的.htaccess我有:

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

.htaccess中的第二行不工作。 有什么建議么?

這是關於的頁面: https://torza.nl/test_environment/metaalboutique/nieuwe_versie/corten-stalen-borderranden-geheel-op-maat-gemaakt?type=1&id=2

下面帶有綠色框的圖像工作正常,紅色不工作正常。 應該指向: https://torza.nl/test_environment/metaalboutique/nieuwe_versie/product_borderrand_hoek_getrapt.php?type=1&id=hoek&image=04

我認為問題在於您提出的第一條規則; 如果我理解正確的話,它也匹配應該根據第二條規則重寫的第二個 URL。 為避免這種情況,您必須將第一條規則調整為不包括-在第一個字符組中

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

或者,如果這不可能,請防止getrapttype之前出現: ([A-Za-z0-9-]+)(?<!getrapt)-type

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM