Home  >  Article  >  Backend Development  >  求教,关于Rewrite中的路径问题。

求教,关于Rewrite中的路径问题。

WBOY
WBOYOriginal
2016-06-23 14:05:27889browse

原本似乎是应该在Apache版块求教的。不过,刚刚问了一次,那里似乎太冷清了。到时先前在这里的请教有比较好的答复。所以重新发帖求教了。

环境描述:
/target.html
/images/image1.png

target.html中引用image1.png:src="images/image1.png"

做URL重写
RewriteRule /paht/source.html target.html

出现的情况是:
呈现的页面中,对于images/image1.png的引用,变成了引用path/images/image1.png。
So, 页面上图片没了。

请问,该如何解决呢?


回复讨论(解决方案)

你的重写规则时这样写的:RewriteRule /paht/source.html target.html
如果不是请贴出详细,方便我们分析。

你的重写规则时这样写的:RewriteRule /paht/source.html target.html
如果不是请贴出详细,方便我们分析。

首先,感谢赐教。

您写的这个重写规则,跟我原本写的似乎区别不大,或者我没看出来。
页面的重新是实现了,但是,出现了资源引用问题。
原本那个target.html里面,有个
target.html、images目录、path目录,这三个项目在目录结构中是同级的。
那么,上述标签在/path/source.html中呈现之后,就变成了请求/path/images/image1.png。
这样……,图片呈现不出来了。

引用 1 楼 nowphp 的回复:你的重写规则时这样写的:RewriteRule /paht/source.html target.html
如果不是请贴出详细,方便我们分析。

首先,感谢赐教。

您写的这个重写规则,跟我原本写的似乎区别不大,或者我没看出来。
页面的重新是实现了,但是,出现了资源引用问题。
原本那个target.html里面,有个

target.html中引用image1.png:src="images/image1.png"

修改为

target.html中引用image1.png:src="/images/image1.png"

target.html中引用image1.png:src="images/image1.png"

修改为

target.html中引用image1.png:src="/images/image1.png"

这种做法,需要修改大量的页面上的资源引用,工作量太大了。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn