douao1579 2012-09-19 11:12
浏览 112
已采纳

.htaccess文件,路径被正确重定向,但未加载图像和CSS

Hi I am using the following lines in my .htaccess file

Options +FollowSymLinks
RewriteEngine on
RewriteBase /coaster/CoasterInsider/
 RewriteRule signup$ index.php?page=signup [L,NC]
 RewriteRule login$ index.php?page=loginHandle [L,NC]
 RewriteRule u/(.*)$ index.php?page=profile&username=$1 [L,NC]

The path is getting redirected properly, but the css,flash and images are not loading. Also if I use the following '/' after any url say,

RewriteRule signup(/?)$ index.php?page=signup [L,NC]

It's not finding any page there, i.e. error 404. I just want my htaccess file to work for both /signup and /signup/

  • 写回答

3条回答 默认 最新

  • dryb38654 2012-09-19 11:21
    关注

    When browser displays:

    http://example.com/coaster/CoasterInsider/signup
    http://example.com/coaster/CoasterInsider/signup/
    

    and encounters a relative URL such as:

    <img src="site/images/photo.png">
    

    It translates the relative URL to (respectively):

    http://example.com/coaster/CoasterInsider/site/images/photo.png
    http://example.com/coaster/CoasterInsider/signup/site/images/photo.png
    

    You should use absolute URLs for assets. Make this a habit:

    <img src="/site/images/photo.png">
    

    Alternately you can use the HTML base tag in your pages which tells browsers how to treat relative URLs. Personally I do not recommend it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

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