Codeigniter 与本地主机 (XAMPP) 中的路径有关的问题

Cod*_*alk 2 php controller codeigniter view path

无论如何,我的代码点火器安装中的索引页(又名 homepage.php)工作正常。

问题在于使用子目录来存储其他页面,目前它的设置如下: 图像1

像加载主页一样http://localhost/VAw_CI/工作正常(加载 homepage.php),这是在 routes.php 中设置的:

$route['default_controller'] = "pages/homepage";
Run Code Online (Sandbox Code Playgroud)

在 config.php 中,我已经设置:

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

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';
Run Code Online (Sandbox Code Playgroud)

$config['index_page'] = '';在上面指定,因为我修改了位于以下位置的 .htaccess htdocs

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*homepage/$0 [PT,L]
Run Code Online (Sandbox Code Playgroud)

但是,如果我尝试登录 homepage.php,目前看起来像: 图像2

它把我送到 http://localhost/VAw_CI/pages/clientlogin

显示: img3

我的控制器设置如下: img4

这里有什么?当我访问http://localhost/VAw_CI,这是有效地加载views->pages->homepage.php观点正确,但似乎任何其他视图不工作,我错过了一些网页路径设置某处其他比我的情况下指数(homepage.php)?

Raj*_*ish 5

请在项目文件夹中创建 .htaccess 文件并写入:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule ^(.*)$ index.php?url=$1 [PT,L] 

</IfModule>
<IfModule !mod_rewrite.c>
 ErrorDocument 404 index.php
</IfModule>
Run Code Online (Sandbox Code Playgroud)

您不需要在配置文件中的 base_url 中定义:

$config['base_url'] = ''; // blank it.
Run Code Online (Sandbox Code Playgroud)