htaccess url重写冲突

时间:2015-11-09 23:54:51

标签: apache .htaccess mod-rewrite url-rewriting

#!/usr/bin/python
# -*- coding: utf-8 -*-

import cv2, os
import numpy as np
from PIL import Image

# For Test
if 0==0:

    cascadePath = "haarcascade_frontalface_default.xml"
    faceCascade = cv2.CascadeClassifier(cascadePath)

    recognizer = cv2.createLBPHFaceRecognizer()
...

这是我到目前为止所尝试的内容

第二个RewriteRule正确地重写了这样的URL:

# RewriteRule ^section-([^.]+)/$ /index.php?section=$1 [L,QSA,NC]
RewriteRule ^section-([^.]+)/([^.]+)-C([^.]+)$ /index.php?section=$1&dossier=$2&catid=$3 [L,QSA,NC]

但如果我取消注释第一行,则第二条规则被破坏

我的问题是我还想重写这个网址:

http://www.example.com/section-test/categorie-one-C001

1 个答案:

答案 0 :(得分:1)

更改规则的顺序,并且为了方便起见也使尾部斜杠可选。

RewriteRule ^section-([^.]+)/([^.]+)-C([^.]+)/?$ /index.php?section=$1&dossier=$2&catid=$3 [L,QSA,NC]
RewriteRule ^section-([^.]+)/?$ /index.php?section=$1 [L,QSA,NC]

让我知道这是怎么回事。