子文件夹中的Codeigniter时路由不起作用

时间:2019-04-03 07:15:21

标签: codeigniter

我的CodeIgniter代码在一个子目录中,因此当我遇到任何其他请求(加载父文件夹索引文件时除外)时,只有索引页有效。

结构为:

  

父文件夹
    index.php
    子文件夹/ codeigniter设置

我在配置中尝试了htaccess代码和request_uri

我想正确打我所有的Codeigniter URL。因为在任何请求下它都会加载父文件夹的index.php文件内容。

2 个答案:

答案 0 :(得分:0)

请为此设置您的.htaccess

DirectoryIndex index.php
RewriteEngine on

RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|jquery|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]

在配置中使用此

$base  = "http://".$_SERVER['HTTP_HOST'];
$base .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url'] = $base;

$config['index_page'] = '';

希望它会起作用:)

答案 1 :(得分:0)

在配置文件中,将您的基本URL设置为托管站点

  

$ config ['base_url'] ='http://whateverthesitepathis';

然后在路线中执行

  

$ route ['default_controller'] ='文件夹/控制器';   $ route ['(:any)'] ='文件夹/控制器/ $ 1';

相关问题