我有很多文件,包括图片,php& js脚本和子文件夹。 我需要使用.htaccess重定向到index.php以获取任何uri 例如:
www.example.com/test should be redirect to index.php
但不应将图像重定向到index.php。相反,它应该直接在浏览器中打印 例如:
www.example.com/sample.jpg should display sample.jpg.
我在.htaccess代码中使用以下代码:
RewriteEngine On
RewriteRule ^(.*)$ index.php
有人可以解释如何让图片显示吗?
答案 0 :(得分:4)
在规则之前添加条件以跳过image / css / js filesdirectories:
RewriteEngine On
RewriteRule !\.(?:jpe?g|gif|bmp|png|tiff|css|js)$ index.php [L,NC]