.htaccess未按预期运行

.htaccess未按预期运行,.htaccess,apache2,.htaccess,Apache2,这似乎非常简单。。但我一辈子都想不出来 我正在设计一个页面:index.html。我想将所有流量重定向到index.html。需要注意的是,我在这一页上有两张图片image1.jpg和image2.jpg。。。这将是一个永远无法完成的重定向。因此,我得出以下结论: # Turn On ReWrite Engine RewriteEngine On # Exclude image1.jpg and image2.jpg from redirecting RewriteCond %{REQUEST

这似乎非常简单。。但我一辈子都想不出来

我正在设计一个页面:
index.html
。我想将所有流量重定向到
index.html
。需要注意的是,我在这一页上有两张图片
image1.jpg
image2.jpg
。。。这将是一个永远无法完成的重定向。因此,我得出以下结论:

# Turn On ReWrite Engine
RewriteEngine On

# Exclude image1.jpg and image2.jpg from redirecting
RewriteCond %{REQUEST_URI} !^/(image1|image2)\.jpg

# Redirect to index.html
RewriteRule . index.html [NC,L]
它起作用了。。如果我去:

http://mysite.com/nothing

它工作得完美无缺。我不明白的是,如果我进入一个目录,图像就不会显示。。即

http://mysite.com/direcotry/file.whatever


当URL位于“n”个目录中时,如何让图像显示???

这是人们在开始使用所谓的漂亮URL时经常遇到的问题


解决方案:解决方案是使用绝对URL包含图像、css和js文件。确保
src
属性中的URL始终以正斜杠(
/
)或
http://

开头这是人们在开始使用所谓的漂亮URL时经常遇到的问题


解决方案:解决方案是使用绝对URL包含图像、css和js文件。确保
src
属性中的URL始终以正斜杠(
/
)或
http://
开头,并且没有安装便于运行测试的
mod_rewrite
,但这可能是您想要的


RewriteCond%{REQUEST\u URI}^/([^/]+/)*(image1 | image2)\.jpg

没有安装便于运行测试的
mod\u rewrite
,但这可能是您想要的

RewriteCond%{REQUEST\u URI}^/([^/]+/)*(图像1 |图像2)\.jpg