有两种页面 -
我想让他们像 - 1. www.mysite.com/about 2. www.mysite.com/winners/2008
我的htaccess就像 -
RewriteEngine On
#removing .php ext(type-1)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
#for type-2 (with parameter)
RewriteRule winners/([0-9]+)/?$ winners.php?y=$1 [L]
RewriteRule winning-photograph/([0-9]+)/?$ winning-photograph.php?y=$1 [L]
RewriteRule award-giving/([0-9]+)/?$ award-giving.php?y=$1 [L]
RewriteRule album-launch/([0-9]+)/?$ album-launch.php?y=$1 [L]
RewriteRule district-fest/([0-9]+)/?$ district-fest.php?y=$1 [L]
RewriteRule lifetime-achievement-awards/([0-9]+)/?$ lifetime-achievement-awards.php?y=$1 [L]
RewriteRule critics-award-for-tv/([0-9]+)/?$ critics-award-for-tv.php?y=$1 [L]
RewriteRule photography-book/([0-9]+)/?$ photography-book.php?y=$1 [L]
这个htaccess的两个部分不能同时工作。我能做什么?另外 - 有没有办法简化第二部分?
答案 0 :(得分:2)
你的第一个RewriteRule基本上阻止了所有其他规则的执行。它为两种类型的URL执行该规则,然后[L]标志阻止它评估其他规则。
我会说最后把这个规则放在最后。首先执行所有更具体的操作,然后将其作为所有其他情况的通用实例,仅在其余规则与当前URL不匹配时进行评估。