如何使Apache重写不破坏图像?
我在example.com上有一个非常简单的html页面。它只包含以下如何使Apache重写不破坏图像?,apache,.htaccess,http,webserver,Apache,.htaccess,Http,Webserver,我在example.com上有一个非常简单的html页面。它只包含以下index.html: <html> <body style="background-color:black;"> <img src="images/picture1.jpg" alt="example" style="width:40%;"> </html> 它正确重定向,但会破坏图像。我相信这是因为对example.com/images/picture1.jpg的请求现在被
index.html
:
<html>
<body style="background-color:black;">
<img src="images/picture1.jpg" alt="example" style="width:40%;">
</html>
它正确重定向,但会破坏图像。我相信这是因为对example.com/images/picture1.jpg的请求现在被重定向到索引页,但我不确定需要向.htaccess中添加什么,以允许在仍将此图像加载到首页的情况下进行全局重定向。添加另一个重写条件,说明该规则仅适用于请求未指向现有文件的情况
RewriteCond %{REQUEST_FILENAME} !-f
因此:
看
RewriteCond %{REQUEST_FILENAME} !-f
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !=/
RewriteRule ^ / [R=301]