htaccess 文件夹和文件异常不起作用
htaccess folder and file exceptions do not work
我在 htaccess 中有说明让所有请求都通过 index.php 文件。但它禁止访问文件夹和文件。因此,如果我尝试转到 /uploads/products/thumbs/file.png,它会导致 index.php?lang=en&category=uploads§ion=products(等),而不是从我添加 RewriteCond 的文件夹中获取文件,以便为现有文件添加例外和文件夹,但由于某些原因它不起作用。
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9_\-\.\(\)]+)?$ index.php?lang=en&category=§ion=products [QSA,L]
RewriteRule ^([a-z0-9_\-\.\(\)]+)/([a-z0-9_\-\.\(\)]+)?$ index.php?lang=en&category=&category_lvl2=§ion=products [QSA,L]
RewriteRule ^([a-z0-9_\-\.\(\)]+)/([a-z0-9_\-\.\(\)]+)/([a-z0-9_\-\.\(\)]+)?$ index.php?lang=en&category=&category_lvl2=&category_lvl3=§ion=products [QSA,L]
按照以下方式获取您的 htaccess 规则文件。请确保在测试您的 URL 之前清除您的浏览器缓存。
RewriteEngine On
RewriteBase /
##Conditions with rules for URL 3 levels of slashes here.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9_\-\.\(\)]+)/([a-z0-9_\-\.\(\)]+)/([a-z0-9_\-\.\(\)]+)?$ index.php?lang=en&category=&category_lvl2=&category_lvl3=§ion=products [QSA,L]
##Conditions with rules for URL 2 levels slashes here.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9_\-\.\(\)]+)/([a-z0-9_\-\.\(\)]+)?$ index.php?lang=en&category=&category_lvl2=§ion=products [QSA,L]
##Conditions with rules for URL 1 level slash here.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9_\-\.\(\)]+)?$ index.php?lang=en&category=§ion=products [QSA,L]
我在 htaccess 中有说明让所有请求都通过 index.php 文件。但它禁止访问文件夹和文件。因此,如果我尝试转到 /uploads/products/thumbs/file.png,它会导致 index.php?lang=en&category=uploads§ion=products(等),而不是从我添加 RewriteCond 的文件夹中获取文件,以便为现有文件添加例外和文件夹,但由于某些原因它不起作用。
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9_\-\.\(\)]+)?$ index.php?lang=en&category=§ion=products [QSA,L]
RewriteRule ^([a-z0-9_\-\.\(\)]+)/([a-z0-9_\-\.\(\)]+)?$ index.php?lang=en&category=&category_lvl2=§ion=products [QSA,L]
RewriteRule ^([a-z0-9_\-\.\(\)]+)/([a-z0-9_\-\.\(\)]+)/([a-z0-9_\-\.\(\)]+)?$ index.php?lang=en&category=&category_lvl2=&category_lvl3=§ion=products [QSA,L]
按照以下方式获取您的 htaccess 规则文件。请确保在测试您的 URL 之前清除您的浏览器缓存。
RewriteEngine On
RewriteBase /
##Conditions with rules for URL 3 levels of slashes here.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9_\-\.\(\)]+)/([a-z0-9_\-\.\(\)]+)/([a-z0-9_\-\.\(\)]+)?$ index.php?lang=en&category=&category_lvl2=&category_lvl3=§ion=products [QSA,L]
##Conditions with rules for URL 2 levels slashes here.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9_\-\.\(\)]+)/([a-z0-9_\-\.\(\)]+)?$ index.php?lang=en&category=&category_lvl2=§ion=products [QSA,L]
##Conditions with rules for URL 1 level slash here.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9_\-\.\(\)]+)?$ index.php?lang=en&category=§ion=products [QSA,L]