我有以下htaccess规则:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^licitatii/([^/]*)/([^/]*)/?$ licitatii.php?orderBy=$1&orderByType=$2 [NC,L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^licitatii/([^/]*)/?$ licitatii.php?orderBy=$1&orderByType=asc [NC,L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^licitatii licitatii.php?orderBy=licitatii_date&orderByType=asc [NC,L,QSA]
当我使用像这样的锚标签时
<a href="/licitatii/licitatii_date/asc">Click</a>
查询参数和网址没有任何反应。
编辑: 我没有得到404,但是在我去了这个网址后,/ licitatii / licitatii-date / asc /&#39;我明白了
而不是
因此,url被更改但是没有提供的输出,它的行为就像我访问了一个不存在的页面(htaccess中的规则) 这是我修改过的htaccess文件:
<IfModule mod_rewrite.c>
RewriteEngine On
Options -Indexes
Options -MultiViews
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^cauta/([a-z0-9\+]+)-([a-z0-9\+]+)-([a-z0-9\+]+)-([a-z0-9\+]+)-([a-z0-9\+]+)-pag([0-9]+)$ cautaLucrare?cautaCategorie=$1&keyWord=$2&cautaDataFrom=$3&cautaDataTo=$4&location=$5&pager=$6 [QSA,L]
#RewriteRule ^cauta/([a-z0-9\+]+)-([a-z0-9\+]+)-([a-z0-9\+]+)-pag([0-9]+)$ cautaLucrare.php?tip_ev=$1&numar_persoane=$2&numar_stele=$3&pager=$4 [QSA,L]
RewriteRule ^adauga_anunt1 landings/landing2.php?source=adwordsLanding2 [NC,L,QSA]
RewriteRule ^adauga_anunt cumFunctioneaza.php [NC,L,QSA]
RewriteRule ^blog/([0-9a-z-/]+)-([0-9]+) blog.php?title=$1&idArt=$2 [NC,L,QSA]
RewriteRule ^blog blog.php [NC,L,QSA]
RewriteRule ^cont/detalii detalii.php [NC,L,QSA]
RewriteRule ^cont/parola-noua parolaNoua.php [NC,L,QSA]
RewriteRule ^cont/istoric istoric.php [NC,L,QSA]
RewriteRule ^cont/oferte-acceptate oferteAcceptate.php [NC,L,QSA]
RewriteRule ^login-fb loginM.php?source=fb [NC,L,QSA]
RewriteRule ^adauga-anunt landings/landing1.php?source=adwordsLanding1 [NC,L,QSA]
RewriteRule ^login loginM.php [NC,L,QSA]
RewriteRule ^facebook loginFB.php [NC,L,QSA]
RewriteRule ^cont-activat contActivat.php [NC,L,QSA]
RewriteRule ^parola-uitata parolaUitata.php [NC,L,QSA]
RewriteRule ^adauga-lucrare adaugaLucrare.php [NC,L,QSA]
RewriteRule ^adauga2 adaugaLucrare2.php [NC,L,QSA]
RewriteRule ^inregistreaza-prestator inregPrest.php [NC,L,QSA]
RewriteRule ^inregistreaza-beneficiar inregBen.php [NC,L,QSA]
RewriteRule ^contact contact.php [NC,L,QSA]
RewriteRule ^termeni-si-conditii tandc.php [NC,L,QSA]
RewriteRule ^despre-noi despre2.php [NC,L,QSA]
RewriteRule ^cauta-lucrare cautaLucrare2.php [NC,L,QSA]
RewriteRule ^cauta cautaLucrare2.php [NC,L,QSA]
RewriteRule ^admin/functii admin.php [NC,L,QSA]
RewriteRule ^admin/statistici statistici.php [NC,L,QSA]
RewriteRule ^logout logout.php [NC,L,QSA]
RewriteRule ^lucrari-active lucrariActive.php [NC,L,QSA]
RewriteRule ^cont/lucrari-active2 lucrariActive2.php [NC,L,QSA]
RewriteRule ^licitatii/([^/]+)?/([^/]+)?/$ licitatii.php?orderBy=$1&orderByType=$2 [NC,L,QSA]
RewriteRule ^licitatii/([^/]+)?/$ licitatii.php?orderBy=$1 [NC,L,QSA]
RewriteRule ^licitatii licitatii.php [NC,L,QSA]
RewriteRule ^contul-meu cont.php [NC,L,QSA]
RewriteRule ^cont2 cont2.php [NC,L,QSA]
RewriteRule ^cont/mesaj-([0-9]+) mesaj.php?id_mesaj=$1 [NC,L,QSA]
RewriteRule ^cont/mesaje-([0-9]+) mesaje.php?pager=$1 [NC,L,QSA]
RewriteRule ^cont/mesaje mesaje.php [NC,L,QSA]
RewriteRule ^cum-functioneaza cumFunctioneaza.php [NC,L,QSA]
RewriteRule ^edit-([0-9]+) editAdd.php?idAnunt=$1 [NC,L,QSA]
RewriteRule ^edit-licitatie-([0-9]+) editOff.php?idLic=$1 [NC,L,QSA]
RewriteRule ^([0-9a-z-/\)\(!?]+)-([0-9]+) page2.php?anuntTitlu=$1&idAnuntToShow=$2 [NC,L,QSA]
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule ^([0-9a-z-/]+)-([0-9]+) cautaLucrare2.php?anuntTitlu=$1&idAnuntToShow=$2 [NC,L,QSA]
RewriteRule ^categorii/([0-9a-z-/]+) categories.php?categoryToShow=$1 [NC,L,QSA]
</IfModule>
稍后编辑:
经过一些研究,当我访问此网址licitatii/licitatii-date/asc
时,它符合此规则:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([0-9a-z-/]+) categories.php?categoryToShow=$1 [NC,L,QSA]
而不是这个规则:
RewriteRule ^licitatii/([a-z-A-Z-0-9-]+)/([^/]+)/?$ licitatii.php?orderBy=$1&orderByType=$2 [NC,L,QSA]
RewriteRule ^licitatii/([a-z-A-Z-0-9-]+)/?$ licitatii.php?orderBy=$1 [NC,L,QSA]
RewriteRule ^licitatii/?$ licitatii.php? [NC,L,QSA]
如何阻止匹配上述规则?
编辑: 我输入网址后得到302。请求如下图所示:
答案 0 :(得分:1)
在关闭MultiViews
时使用这种方法,在第3条规则中使用锚点并使用+
量词而不是*
:
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^licitatii/([^/]+)/([^/]+)/?$ licitatii.php?orderBy=$1&orderByType=$2 [NC,L,QSA]
RewriteRule ^licitatii/([^/]+)/?$ licitatii.php?orderBy=$1&orderByType=asc [NC,L,QSA]
RewriteRule ^licitatii/?$ licitatii.php?orderBy=licitatii_date&orderByType=asc [NC,L,QSA]