如何从codeigniter项目中的URL中删除index.php [英] How to remove the index.php from url in codeigniter project

查看:29
本文介绍了如何从codeigniter项目中的URL中删除index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Codeigniter中创建一个网站.我知道这是非常常见的问题,并且有很多关于Stack Overflow的解决方案.我几乎尝试了所有方法,但对我没有帮助.

I am creating a website in Codeigniter. This is very common issue I know and there are lots of solutions on Stack Overflow. I try almost all but nothing is helpful for me.

我只想从我的网址中删除index.php.有人告诉我该怎么做吗?

I just want to remove index.php from my url. Anybody please tell me how can I do it?

我已从配置文件的 $ config ['index_page'] 部分中删除了index.php

I have removed index.php from the config file's $config['index_page'] section

我还检查了 $ config ['uri_protocol'] ='AUTO'; 模式尝试同时使用模式auto和 REQUEST_URI .

I also checked $config['uri_protocol'] = 'AUTO'; mode try both mode auto and REQUEST_URI.

我现在的.httaccess文件结构是这样的:

My .httaccess file structure right now is this:

<IfModule authz_core_module>
    Require all denied
</IfModule>
<IfModule !authz_core_module>
    Deny from all
</IfModule>

<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>

有人可以告诉我该怎么做吗?

Can anybody please tell me how to do it?

推荐答案

=>更改配置文件:-

=> Change in config file :-

$config['base_url'] = 'http://123456/proj/';
$config['index_page'] = '';

=>更改.htaccess文件:-

=> change in .htaccess file :-

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]

这篇关于如何从codeigniter项目中的URL中删除index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆