我有以下内容:
main
+ project1
+ project2
这里main是文档根目录,projectXXX是子文件夹,里面有单独的项目
我需要在每个子文件夹(projectXXX)中添加一个htaccess文件,所以当我键入html绝对链接(例如:<img src='/images/image.jpg'>
)指向我当前所在的文件夹时。
我试试这个
RewriteEngine on
RewriteBase /
但是当我输入src =&#39; /images/image.jpg'它正在寻找一个图像到文档根目录而不是&#34;子文件夹根目录&#34;
感谢任何帮助
答案 0 :(得分:0)
In project1
you would use RewriteBase /project1
, but you cannot use /images/foo.jpg
to refer to project1/images/foo.jpg
- how would Apache HTTPD know in which folder to look for the image?
There is a way however: add this to to your <head>
in HTML files in project1/
:
<base href="/project1/">
See base tag for more info.