在参照:多规则 Apache 重写
虽然这对于多层次的项目深入挖掘非常有用,但我仍然需要一个在规则之外运行的 admin.php 页面。目前,在此规则集下,标准页面/脚本不会运行。
有什么想法/主意吗?
RewriteRule ^mr/index.php$ - [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/?$ /mr/index.php?product_group=$1&product_family=$2&product_category=$3&product_sub_category=$4&product=$5 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/?$ /mr/index.php?product_group=$1&product_family=$2&product_category=$3&product_sub_category=$4 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/?$ /mr/index.php?product_group=$1&product_family=$2&product_category=$3 [L]
RewriteRule ^([^/]*)/([^/]*)/?$ /mr/index.php?product_group=$1&product_family=$2 [L]
RewriteRule ^([^/]*)/?$ /mr/index.php?product_group=$1 [L]
更新:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ - [L]
RewriteRule ^index.php$ - [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/?$ index.php?n_section=$1&n_product_group=$2&n_product_family=$3&n_product_category=$4&n_product_subcategory=$5 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/?$ index.php?n_section=$1&n_product_group=$2&n_product_family=$3&n_product_category=$4 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/?$ index.php?n_section=$1&n_product_group=$2&n_product_family=$3 [L]
RewriteRule ^([^/]*)/([^/]*)/?$ index.php?n_section=$1&n_product_group=$2 [L]
RewriteRule ^([^/]*)/?$ index.php?n_section=$1 [L]
答案1
将这些行放在顶部,现有行的上方RewriteRule
。它将检查请求的文件是否存在,如果存在,它将跳过其余的重写过程,忽略所有后续规则。
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ - [L]