【问题标题】:Bootstrap 3 notworking with PHP MVC .htaccessBootstrap 3 不适用于 PHP MVC .htaccess
【发布时间】:2015-06-17 04:30:31
【问题描述】:

当我创建 MVC 应用程序时,Bootstrap 样式没有访问。我的 .htaccess 文件是这样的

RewriteEngine on
RewriteRule !.(js|css|ico|gif|jpg|png|swf|ttf|eot|svg|woff|GIF)$ index.php
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

我的html编码是这样的

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <link href="../css/bootstrap.min.css" rel="stylesheet" type="text/css"/>

    </head>
    <body>

        <h1>efrg</h1>
    </body>
</html>

删除 .htaccess 文件后,它可以正常工作。 .htaccess 文件有什么问题?我也正确集成了 bootstrap.min.css 文件

这是我的 mvc 代码

<?php

$url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

$urlParams = explode('/', $url);

if (count($urlParams) === 5) {
    header("location:$url"."users/login");
} else {

    $modelName = $urlParams[4] . 'Model';
    require "./model/$modelName.php";

    $controllerName = $urlParams[4] . 'Controller';
    require "./controller/$controllerName.php";

    $actionName = $urlParams[5] . 'Action';

    $obj = new $controllerName();
    $obj->$actionName();

    include "./view/$urlParams[4]/$urlParams[5].php";
}
?>

【问题讨论】:

  • 什么是没有工作的css或js指定
  • 我没有找到你@abhi Ahere
  • 你的问题不明确
  • 我的引导样式不起作用。
  • 当您使用 .htaccess 时,如果您提供绝对路径,则可以访问每个文件

标签: php css .htaccess twitter-bootstrap


【解决方案1】:

没有人注意到,如果 header 包含在 require 或 include 方法中,则某些功能主义者无法正常工作。正如我之前提到的,我的引导程序没有按原样工作。我使用包含而不是 header()。这就对了。没有错误..代码运行良好

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-16
    • 1970-01-01
    • 2017-05-05
    • 2015-02-23
    • 1970-01-01
    • 2017-01-23
    • 2017-12-19
    • 1970-01-01
    相关资源
    最近更新 更多