dongsi7759 2018-03-21 17:58 采纳率: 100%
浏览 80
已采纳

没有加载.htaccess css文件的seo友好网址[重复]

This question already has an answer here:

i have a url which looks like

https://sparkle.000webhostapp.com/movie.php?id=16

i want to change it as

https://sparkle.000webhostapp.com/movie/16

i have created .htaccess file as

   Options -MultiViews
RewriteEngine On

# redirect "/movie.php?id=xxx" to "/movie/xxx"
RewriteCond %{THE_REQUEST} \s/movie\.php\?id=([0-9]+)\s [NC]
RewriteRule ^ /movie/%1? [R=301,L]

# internally rewrite "/movie/xxx" to "/movie.php?id=xxx"
RewriteRule ^movie/([0-9]+)$ /movie.php?id=$1 [L]

but the problem is the style file ,i.e.,css file is not loaded. no styles are defined in the link

</div>
  • 写回答

1条回答 默认 最新

  • dsgw3315 2018-03-21 18:14
    关注

    If your CSS is referenced like this: <link rel="stylesheet" href="homepage.css" />, it will be relative to the request's path!

    Initially, requests to /movie.php?id=123 would render a page whose css was assumed to be at /homepage.css.

    But, when you create that rewrite, the request is understood as /movie/123, and the css is assumed to be at /movie/homepage.css.

    To get around this problem, begin the reference to your CSS with a /, so that it's always in reference to the web root.

    The updated <link> tag should be <link rel="stylesheet" href="/homepage.css" />

    You can confirm this by checking your browser's error console and looking for something like "GET https://sparkle.000webhostapp.com/movie/homepage.css 404"

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

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据