.htaccess htaccess文件夹和文件异常不起作用

.htaccess htaccess文件夹和文件异常不起作用,.htaccess,mod-rewrite,url-rewriting,query-string,friendly-url,.htaccess,Mod Rewrite,Url Rewriting,Query String,Friendly Url,我在htaccess中有说明,可以通过index.php文件发出所有请求。但它会禁用对文件夹和文件的访问。因此,如果我尝试转到/uploads/products/thumbs/file.png,它将导致index.php?lang=en&category=uploads§ion=products(etc),而不是从我添加了RewriteCond的文件夹中获取文件,以添加现有文件和文件夹的异常,但由于某些原因,它不起作用 RewriteEngine On RewriteBase / Re

我在htaccess中有说明,可以通过index.php文件发出所有请求。但它会禁用对文件夹和文件的访问。因此,如果我尝试转到/uploads/products/thumbs/file.png,它将导致index.php?lang=en&category=uploads§ion=products(etc),而不是从我添加了RewriteCond的文件夹中获取文件,以添加现有文件和文件夹的异常,但由于某些原因,它不起作用

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([a-z0-9_\-\.\(\)]+)?$ index.php?lang=en&category=$1&section=products [QSA,L]
RewriteRule ^([a-z0-9_\-\.\(\)]+)/([a-z0-9_\-\.\(\)]+)?$ index.php?lang=en&category=$1&category_lvl2=$2&section=products [QSA,L]
RewriteRule ^([a-z0-9_\-\.\(\)]+)/([a-z0-9_\-\.\(\)]+)/([a-z0-9_\-\.\(\)]+)?$ index.php?lang=en&category=$1&category_lvl2=$2&category_lvl3=$3&section=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=$1&category_lvl2=$2&category_lvl3=$3&section=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=$1&category_lvl2=$2&section=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=$1&section=products [QSA,L]

奇怪的我尝试过这个解决方案,但没有成功。现在是了。也许是缓存。谢谢lot@TimurGafforov,不客气,很乐意帮忙。事实上,如果我们看到,我增加了两个条件和两条规则,同时改变了它们的顺序,这就是为什么它起作用了,干杯。