我的.htaccess文件

时间:2017-09-22 23:59:32

标签: apache .htaccess mod-rewrite

我的.htaccess文件非常困难

(Apache)httpd.conf:以下是未注释的:

mod_rewrite
LoadModule rewrite_module modules/mod_rewrite.so

我的文档根目录:

DocumentRoot "f:/www"
<Directory "f:/www">

我的index.html文件位于:

F:\www\portfolio2

我的.htaccess文件位于:

F:\www\portfolio2

在我的.htaccess文件中:

RewriteEngine on
RewriteRule ^portf/([0-9a-zA-Z]+) index.html?p=$1 [NC,L]

目录:

F:\www\portfolio2\portf

不存在,但我很确定它不需要,对吧?

在我的index.html中:

<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="css/portfolio.css" rel="stylesheet">
<script src="jquery/jquery-3.2.1.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="js/javascript.js"></script>

当我测试网址时:

http://localhost/portfolio2/portf/qweasd

我的控制台记录以下错误/警告:

Uncaught SyntaxError: Unexpected token <    jquery-3.2.1.min.js:1
Uncaught SyntaxError: Unexpected token <    bootstrap.min.js:1
Uncaught SyntaxError: Unexpected token <    javascript.js:1

Resource interpreted as Stylesheet but transferred with MIME type text/html:
"http://localhost/portfolio2/portf/bootstrap/css/bootstrap.min.css".
                                            qweasd:20

Resource interpreted as Stylesheet but transferred with MIME type text/html:
"http://localhost/portfolio2/portf/css/portfolio.css".
                                            qweasd:21

从我看到的,它认为我有一个名为“portf”的目录,我没有。

我做错了吗?

编辑:我忘了提及,页面加载但不加载CSS,JavaScript等。

EDIT2 已解决。我已将RewriteBase /portfolio2/添加到.htaccess,我在整个网站中使用了相对网址。我还替换了rel="stylesheet",现在正在应用样式。然后我添加了<base href="/portfolio2/">  在CSS和JavaScript导入之前的<head>中。干杯!

0 个答案:

没有答案
相关问题