php中的htaccess问题
有两种页面:php中的htaccess问题,php,.htaccess,Php,.htaccess,有两种页面: www.mysite.com/about.php www.mysite.com/winners.php?y=2008 我想让他们像- 1.www.mysite.com/about 2.www.mysite.com/winners/2008 我的访问权限就像- RewriteEngine On #removing .php ext(type-1) RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC
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的两个部分不同时工作。我能做什么?还有-有没有办法简化第二部分?您的第一条重写规则基本上阻止了所有其他规则的执行。它对两种类型的URL都执行该规则,然后[L]标志阻止它对其他规则进行求值
我要说的是,把这条规则放在最后。首先执行所有更具体的规则,然后将其作为所有其他情况的通用规则,只有在其他规则与当前URL不匹配时才进行评估。是否要隐藏或编码URL?@Ankit您是说干净的URL吗@Emrul Hasan您可以尝试将
[L]
替换为[L,QSA]
,它们以何种方式不起作用?您可以对url功能进行编码,而不是使用干净的url。请详细介绍干净的url