Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codeigniter-控制器在子文件夹中,从url中删除index.php_Php_.htaccess_Codeigniter_Pretty Urls - Fatal编程技术网

Codeigniter-控制器在子文件夹中,从url中删除index.php

Codeigniter-控制器在子文件夹中,从url中删除index.php,php,.htaccess,codeigniter,pretty-urls,Php,.htaccess,Codeigniter,Pretty Urls,如果控制器文件夹中有一些控制器,子文件夹中有一个控制器,如何从URL中删除“index.php”? 例如,我的前端url如下所示:domain.com/site/contact.html 我希望我的后端url如下所示:domain.com/system/settings/profile.html,其中系统不是控制器,只是控制器文件夹中的子文件夹。 当我键入domain.com/index.php/system/settings/profile.html时,一切正常,只是看起来不太对劲。 下面是m

如果控制器文件夹中有一些控制器,子文件夹中有一个控制器,如何从URL中删除“index.php”? 例如,我的前端url如下所示:domain.com/site/contact.html 我希望我的后端url如下所示:domain.com/system/settings/profile.html,其中系统不是控制器,只是控制器文件夹中的子文件夹。 当我键入domain.com/index.php/system/settings/profile.html时,一切正常,只是看起来不太对劲。 下面是my routes.php文件中的内容:

$route['default_controller'] = "site";
$route['system'] = "system/login";
$route['404_override'] = 'errors/error_404';
$route['system'] = "system/login";
以下是我的.htaccess文件中的内容:

RewriteEngine on
RewriteCond $1    !^(index\.php|img|css|public|tmp|download|javascript|rte|document|xajax_js|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

谢谢。

您可以尝试设置
RewriteBase
RewriteBase/
RewriteBase/site/
来删除index.php

在project的根文件夹中创建一个.htaccess文件,并编写以下代码:

<IfModule mod_rewrite.c>

RewriteEngine On

    RewriteCond $1 !^(index\.php|resources|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]

</IfModule>

重新启动发动机
1美元^(索引\.php | resources | robots\.txt)
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php/$1[L,QSA]
并保存它

从您的URl中删除index.php并享受它。
请注意.htacess不在本地计算机上运行。

要从URL中删除index.php,请首先检查apache中是否启用了mod_rewrite,然后将此添加到.htaccess文件中

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
在.htaccess文件中,将.htaccess文件移到index.php位置附近

/var/www/CodeIgniter/index.php
/var/www/CodeIgniter/.htaccess
在config.php的config文件夹集中

$config['index_page'] = '';

我的问题是routes.php文件中的保留控制器名称:

$route['default_controller'] = "site";
$route['system'] = "system/login";
$route['404_override'] = 'errors/error_404';
$route['system'] = "system/login";

无法将子文件夹命名为“system”,因为根文件夹中有一个文件夹“system”。

这也不起作用。我需要.htaccess文件中出现某种异常。无论如何,谢谢你。