【问题标题】:Css file is missing when I use .htaccess使用 .htaccess 时缺少 Css 文件
【发布时间】:2017-04-26 08:32:57
【问题描述】:
RewriteEngine On

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

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

【问题讨论】:

  • 您已经发布了 .htaccess 文件的内容,还请说明什么是不工作的。标题提到了一个 css 文件 - 它的 URL 是什么,当您尝试加载它时会发生什么?

标签: php css .htaccess


【解决方案1】:

因为您更改了根目录(使用/post/ 添加一级)。
在您的post.php HTML <head> 中添加这一行:

<base href="/">

或者在css文件名前加上/

<link rel="stylesheet" ... href="/css/name.css">

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-27
    • 1970-01-01
    • 2010-11-17
    相关资源
    最近更新 更多