Codeigniter base_url 窃听,还是 url_rewriting?

Code igniter base_url bugging, or url_rewriting?

提前感谢你们给我的所有帮助。 我现在有点绝望,我不知道该怎么办。我想问题出在我的 base_url 上,但它也可能出在我的 .htaccess 上 url_rewriting 上? 我有一个在本地主机上运行的代码点火器项目。

每当我点击 link 时,它都会添加一个 "localhost:8888" :

我有一个包含以下 url 的页面:http://localhost:8888/my_project/ 当我点击此页面上的 link 时,它指向我: http://localhost:8888/localhost:8888/my_project/procedure/student

我不明白为什么要在两者之间添加 localhost:8888? (如果我手动取消 url 中的 localhost:8888,页面会正常工作并加载)

这是定义我的 base_url 的常量文件:

define("URL", (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] );
define("SITE_URL", 'http://localhost:8888/my_project/');

这是我的 .htaccess :

Options +FollowSymlinks -Indexes
RewriteEngine On
#RewriteBase /

## in case the URL is not an actual FILE
RewriteCond %{REQUEST_FILENAME} !-f

## or an actual directory
RewriteCond %{REQUEST_FILENAME} !-d

## send everything to the index, for MVC
#RewriteRule ^.*$ ./index.php

RewriteCond  !^(index\.php)
RewriteRule ^(.*)$ index.php?/ [L,QSA]

DirectoryIndex index.php index.html

这也是我的 config.php base_url 行:

$config['base_url'] = 'http:/localhost:8888/my_project/';

links 在视图中生成如下:id);?> 所以应该给出例如 localhost:8888/my_project/teacher/7 但是当我悬停 link 有 localhost:8888/localhost:8888/my_project/teacher/7

我做错了什么吗?

在此先感谢您的帮助!

经过一系列的调试(通过),结论是错误在配置文件中错误写入的基础url。 它应该从:

$config['base_url'] = 'http:/localhost:8888/my_project/';

$config['base_url'] = 'http://localhost:8888/my_project/';// notice double slash at beginning

因此,有人向我推荐了荣誉勋章,我仍然在想,我应该把它当作指出我们每个人都经历过的这个愚蠢的错误,还是应该等待现场某个地方出现有史以来最大的错误,然后再接受它当之无愧的认可。 :)