douzai8285 2014-09-15 13:57
浏览 41
已采纳

htaccess正斜杠深入文件夹

I have this simple redirect rules:

RewriteEngine On

RewriteRule   ^tags/([^\.]+)/?$ home.php?search=$1    [L]

So if a url looks like

  http://example.org/path/to/folder/tags/exampleTag

It is redirected to

http://example.org.com/path/to/folder/home.php?search=exampleTag

It works, it redirects to home.php, but the problem is things and images on home.php. Apparently, the path when loading the images turns to http://example.org/path/to/folder/tags/imgs/img.jpg

Instead of: http://example.org/path/to/folder/imgs/img.jpg

I.e, during redirection, the home.php loads things like it is in the tags folder and because they are not, the images do not get loaded.

How can I solve this?

On home.php I am using html to load images like this:

Both the .htaccess, home.php and the imgs folder are on the same folder

  • 写回答

1条回答 默认 最新

  • dtd793353 2014-09-15 15:20
    关注

    Add this to the header of your pages:

    <base href="/path/to/folder/" />
    

    so that all of your relative paths use the correct URI base.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料