我正在使用 codeigniter,但我坚持使用 css/js 的路径,删除了 index.php 和 .htaccess。我正在尝试加载我的资源,但我总是在我的
我的 htdocs 文件夹中有以下结构
Course
|
|
Project
|
|
js
css
.htaccess
application
|
|
view
|
|
templates
|
|
footer.php
在我的footer.php我有
<script type="text/javascript" src="../../../js/script.js"></script>
此 script.js 包含的唯一内容是应该在 document.ready 上弹出的警报。
在我的配置文件中,我将基本 url设置为
$config['base_url'] = 'http://localhost/course/project/';
在我的.htaccess中我有(有了这个我能够从 url 中删除 index.php 现在我冲浪到http://localhost/course/project/profile
而不是http://localhost/course/project/index.php/profile
)虽然这不是像codeigniter 指南中描述的那样正确的方法 - 删除 index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
IndexIgnore *
但这在控制台中给了我这个错误,用于加载我的 js 资源
GET http://localhost/js/script.js 404 (Not Found)
在上面的代码之前,我的 .htaccess 中有这个,就像他们网站上描述的那样
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt)
RewriteRule ^(.*)$ course/project/index.php/$1 [L]
但这给了我
GET http://localhost/js/script.js 404 (Not Found) profile:80
http://localhost/course/project/profile
当我上网时
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at postmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
我花了几个小时跟踪和更改 url、路径等,现在我都对此感到困惑。我希望有人可以帮助我吗?