由网友(你╮这么近那么远つ)分享简介:我想要使用htaccess的重定向到一个文件,但不能显示图像。I'm trying to use htaccess redirect to a file, but can't get the image to display.我要重定向任何要求mydomain.com和www.mydomain.com到www.my...
我想要使用htaccess的重定向到一个文件,但不能显示图像。
I'm trying to use htaccess redirect to a file, but can't get the image to display.
我要重定向任何要求mydomain.com和www.mydomain.com到www.mydomain.com/test.html~~V
I want to redirect ANY request to mydomain.com or www.mydomain.com to www.mydomain.com/test.html
这是我的htaccess文件的内容:
This is the content of my htaccess file:
# Turn rewriting on
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !=/test.html
RewriteCond %{REQUEST_URI} !=*.png$ [NC]
RewriteRule .* /test.html
我在我的test.html文件中此行的code:
I have this line of code in my test.html file:
<img src="image.png" alt="My Image">
但图像不显示在所有的,我只是得到一个破碎的形象。我也尝试过使用绝对路径的图像,同样的事情。
But the image doesn't display at all, I just get a broken image. I also tried using absolute path for image, same thing.
推荐答案
尝试使用以下替换你的.htaccess文件
Try replacing your .htaccess file with the following
# Turn rewriting on
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
#if the request does not end with test.html or is not a .png
RewriteCond %{REQUEST_URI} !(test.html|.png)$ [NC]
# Rewrite it to test.html
RewriteRule .* /test.html [L]
相关推荐
最新文章