我的htaccess
文件中有以下代码
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^(online-shop)/?$ $1/home [L,NC]
RewriteRule ^(my-integra)/?$ $1/home [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/?$ index.php?id=$1 [QSA,NC]
RewriteRule ^(blog)/(post|tags)/([\w-]+)/?$ index.php?id=$1&type=$2&unique=$3 [QSA,NC]
RewriteRule ^(blog)/(archives)/([0-9]{4})/([0-9]{2})?$ index.php?id=$1&type=$2&year=$3&month=$4 [QSA,NC]
底部的两条规则似乎不起作用,如果我访问domain.com/blog/post/post-1
它没有显示正确的网页而只显示index.php?id=blog/post/post1
而不是index.php?id=blog&type=post&unique=post1
答案 0 :(得分:1)
RewriteCond
仅适用于下一个RewriteRule
。同时将通用规则作为最后一条规则。
这样做:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^(online-shop)/?$ $1/home [L,NC]
RewriteRule ^(my-integra)/?$ $1/home [L,NC]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(blog)/(post|tags)/([\w-]+)/?$ index.php?id=$1&type=$2&unique=$3 [QSA,NC,L]
RewriteRule ^(blog)/(archives)/([0-9]{4})/([0-9]{2})?$ index.php?id=$1&type=$2&year=$3&month=$4 [QSA,NC,L]
RewriteRule ^(.+?)/?$ index.php?id=$1 [QSA,L]