我有一個網站,我們目前正在努力在以下目錄結構上:的.htaccess忽略的RewriteCond
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以這種方式行事,我該如何解決它?
你知道RewriteConds只適用於直接跟隨它們的一個RewriteRule ...? – CBroe