我今天正在更新一个网站,令我惊讶的是,我的一个新的RewriteRules不起作用。我在所有规则上使用相同的“语法”,但仍然存在问题。
我的代码是:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^produktinformation-om-(.*)/?$ /produktinformation.php?product=$1
RewriteRule ^nyhet-(.*)-(.*)/?$ /merinfonyhet.php?id=$2
RewriteRule (sv|en|cn)/$ /actions/action.set.language.php?lang=$1
RewriteRule (sv|en|cn)/(.+)/$ /actions/action.goto.page.php?lang=$1&page=$2
## MENU START
RewriteRule ^information/?$ /information.php
RewriteRule ^kontakt/?$ /kontakt.php
RewriteRule ^nyheter/?$ /nyheter.php
RewriteRule ^kvalitet/?$ /kvalitet.php
RewriteRule ^produkter/?$ /produkter.php
RewriteRule ^antioxidanter/?$ /category.php?cat=0 [NC,L]
RewriteRule ^vitaminer/?$ /category.php?cat=1 [NC,L]
RewriteRule ^mineraler/?$ /category.php?cat=2 [NC,L]
RewriteRule ^viktkontroll/?$ /category.php?cat=3 [NC,L]
RewriteRule ^leder-muskler/?$ /category.php?cat=4 [NC,L]
RewriteRule ^omega-3/?$ /category.php?cat=5 [NC,L]
RewriteRule ^smart-mat/?$ /category.php?cat=6 [NC,L]
RewriteRule ^syn-tanke/?$ /category.php?cat=7 [NC,L]
RewriteRule ^kraft-energi-fokus/?$ /category.php?cat=8 [NC,L]
RewriteRule ^hjartat-karl/?$ /category.php?cat=9 [NC,L]
RewriteRule ^nedstamndhet-stress/?$ /category.php?cat=10 [NC,L]
RewriteRule ^samlevnad-lust-potens/?$ /category.php?cat=11 [NC,L]
RewriteRule ^resa/?$ /category.php?cat=12 [NC,L]
RewriteRule ^laktosintolerans/?$ /category.php?cat=13 [NC,L]
RewriteRule ^hud-o-naglar/?$ /category.php?cat=14 [NC,L]
RewriteRule ^halsokost/?$ /category.php?cat=15 [NC,L]
RewriteRule ^halsomat/?$ /category.php?cat=16 [NC,L]
RewriteRule ^barnmat/?$ /category.php?cat=17 [NC,L]
RewriteRule ^pannkakor/?$ /category.php?cat=18 [NC,L]
RewriteRule ^vafflor/?$ /category.php?cat=19 [NC,L]
RewriteRule ^vlcdFrukost/?$ /category.php?cat=20 [NC,L]
RewriteRule ^vlcdSoppor/?$ /category.php?cat=21 [NC,L]
RewriteRule ^vlcdShakesDrycker/?$ /category.php?cat=22 [NC,L]
RewriteRule ^fettforbranning/?$ /category.php?cat=23 [NC,L]
RewriteRule ^kolhydratsblockerare/?$ /category.php?cat=24 [NC,L]
RewriteRule ^grot/?$ /category.php?cat=25 [NC,L]
RewriteRule ^modersmjolksersattning/?$ /category.php?cat=26 [NC,L]
RewriteRule ^valling/?$ /category.php?cat=27 [NC,L]
RewriteRule ^omega3-junior/?$ /category.php?cat=28 [NC,L]
RewriteRule ^stillavatten/?$ /category.php?cat=29 [NC,L]
RewriteRule ^lattkolsyrat/?$ /category.php?cat=30 [NC,L]
## MENU END
我得到的问题是“ RewriteRule ^ stillavatten /?$ /category.php?cat=29 [NC,L] ”代码底部的第三位。
如果我写的是: http://www.thepage.com/stillavatten/
,那么我会得到一个空白页的 302响应。
如果我最后拿走“ / ”,我会转到正确的页面。
如果我在任何其他重写上尝试相同的操作,无论是否有“ / ”都可以使用。
我尝试了很多不同的解决方案,但没有成功,这让我发疯了:)我在每一行都添加了“[NC,L]”,但这并没有帮助。
任何帮助都会非常感激。
答案 0 :(得分:1)
GET /stillavatten/
也符合规则4匹配模式(sv|en|cn)/$
。你忘了锚定这个:)