我希望有人可以帮助我。我目前正试图让我的网站更友好,并且与.htaccess有一些奇怪的问题。
这都在我的测试服务器上。设计师部分工作正常,没有设计师名称“cquoi等”之前的“homeware-designer /”。一切都很好,直到我添加最后一个mage
然后它全部停止工作,相对链接不再正常工作。我删除了RewriteRule mage designerdata.php?search=4
,这一切都开始了。一旦我添加homeware-designer/etc
所有工作再次正常????任何人都可以告诉我可能会发生什么。此外,如果没有^foo$
,某些规则将无效,但大多数规则在没有^$
分隔符的情况下仍然有效,而且大多数规则在^ $字符串分隔符中都不起作用。在尝试将其放在实时服务器上之前,我只需要了解发生了什么。
Options +FollowSymLinks -Indexes
RewriteEngine on
RewriteBase /
RewriteRule designer-homeware index.php
#------------------ Living ---------------
RewriteRule living-room-hallway category.php?collection=1
RewriteRule designer-shelves-storage contentdata.php?collection=1&type=17
RewriteRule designer-cushions-pouffes contentdata.php?collection=1&type=1
rewriterule designer-coat-hat-racks contentdata.php?collection=1&type=19
rewriterule designer-lighting contentdata.php?collection=1&type=25
rewriterule living-room-accessories contentdata.php?collection=1&type=4
#----------------- Eating ----------------
RewriteRule dining-room-eating category.php?collection=2
rewriterule designer-tableware contentdata.php?collection=2&type=5
rewriterule designer-glassware contentdata.php?collection=2&type=6
rewriterule dining-room-accessories contentdata.php?collection=2&type=8
#----------------- Bathing ----------------
RewriteRule ^bathroom$ category.php?collection=5
RewriteRule bathroom-accessories contentdata.php?collection=5&type=11
#----------------- Kids -------------------
RewriteRule ^childrens-decor$ category.php?collection=6
RewriteRule ^designer-childrens-decor$ contentdata.php?collection=6&type=20
#----------------- Garden ------------------
RewriteRule garden category.php?collection=7
RewriteRule garden-accessories contentdata.php?collection=7&type=21
#----------------- Art ---------------------
rewriterule designer-prints contentdata.php?collection=8&type=24
#----------------- Designers --------------
RewriteRule homeware-designers designer.php
RewriteRule homeware-designer/cquoi designerdata.php?search=7
RewriteRule homeware-designer/remember designerdata.php?search=8
RewriteRule homeware-designer/terafue designerdata.php?search=10
RewriteRule homeware-designer/r-bernier designerdata.php?search=11
RewriteRule homeware-designer/c-l-boym designerdata.php?search=21
RewriteRule homeware-designer/andre-klauser designerdata.php?search=22
RewriteRule homeware-designer/shin-azumi designerdata.php?search=23
RewriteRule homeware-designer/alejandro-ruiz designerdata.php?search=24
RewriteRule homeware-designer/tord-boontje designerdata.php?search=25
RewriteRule homeware-designer/sibo-home-concept designerdata.php?search=13
RewriteRule homeware-designer/zafferano designerdata.php?search=14
RewriteRule homeware-designer/klevering designerdata.php?search=15
RewriteRule homeware-designer/dutch-waaren designerdata.php?search=16
RewriteRule homeware-designer/vintage-casa designerdata.php?search=17
RewriteRule homeware-designer/hubsch-denmark designerdata.php?search=18
RewriteRule homeware-designer/serholt-sweden designerdata.php?search=19
RewriteRule homeware-designer/lazis designerdata.php?search=20
RewriteRule homeware-designer/atlantis designerdata.php?search=26
RewriteRule homeware-designer/mage designerdata.php?search=4
答案 0 :(得分:0)
对于这些精确网址规则,最好包含^$
分隔符。需要^$
分隔符的问题是某些规则是其他规则的子集。例如,如果您没有分隔符,则bathroom
规则会捕获网址bathroom-accessories
。一般来说,如果你知道你想要的整个网址,那么最好有分隔符。
另一个问题是这些规则都经过检查,即使它们匹配也是如此。在大多数情况下,这不是一个问题,但是像浴室一样,有些可能会在不止一条规则上匹配。要解决此问题,请将[L]
放在规则的末尾,以表明它是匹配的最后一条规则 - 也就是说,如果匹配则完成并退出。
通常还包括一个NC
标志,对于无案例,不管它是不是大写或小写。
RewriteRule designer-homeware index.php [NC,L]
#------------------ Living ---------------
RewriteRule living-room-hallway category.php?collection=1 [NC,L]
RewriteRule designer-shelves-storage contentdata.php?collection=1&type=17 [NC,L]
etc.
试一试,看看是否有帮助。我没有明确地看到法师规则有任何问题,但L和分隔符至少会使规则不会相互重叠。