对于我们目前正在处理的网站,我有以下目录结构:
root
- admin/
- assets/
- cache/
- images/
- .htaccess
- category.php
- image.php
- resize.php
我想根据一些条件重写 URL,并使用.htaccess
. 出于某种原因,Apache 似乎完全忽略了RewriteCond
我添加的规则。这是该文件的副本.htaccess
:
DirectoryIndex index.php category.php
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Image rewrites:
RewriteRule ^([^/]+)/([0-9]+)/(.*)$ resize.php?function=resizeRatio&width=$2&src=images/$1/$3 [L]
RewriteRule ^([^/]+)/([^/]+)([0-9]+)/(.*)$ resize.php?function=resizeRatio&width=$3&src=images/$1/$2/$4 [L]
RewriteRule ^([^/]+)/([0-9]+)x([0-9]+)/(.*)$ resize.php?function=resizeCrop&width=$2&height=$3&src=images/$1/$4 [L]
RewriteRule ^([^/]+)/([^/]+)([0-9]+)x([0-9]+)/(.*)$ resize.php?function=resizeCrop&width=$3&height=$4&src=images/$1/$2/$5 [L]
# Category rewrites:
RewriteRule ^([^/]+)/$ category.php?parent=$1 [L]
RewriteRule ^([^/]+)/([^/]+)/$ category.php?parent=$1&child=$2 [L]
RewriteRule ^([^/]+)/([^/]+).(.*)$ image.php?image=$2.$3&parent=$1 [L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+).(.*)$ image.php?image=$3.$4&parent=$1&child=$2 [L]
尝试访问时/admin/
,我被定向到重写的页面category.php?category=admin/
。
为什么 Apache 会以这种方式运行,我该如何解决?