CodeIgniter从网址中删除index.php [英] CodeIgniter removing index.php from url

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

问题描述

我当前的网址看起来像这样 [mysite] index.php / [rest of the slug]

我要剥离 index.php

My current urls look like this [mysite]index.php/[rest of the slug].
I want to strip index.php from these urls.

mod_rewrite 在我的apache2服务器上启用。在 config $ config ['index_page'] ='';

mod_rewrite is enabled on my apache2 server. In config, $config['index_page'] = '';

我的代码符号 .htaccess 文件包含

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

但仍然不工作。我在哪里错了?

But still it is not working. Where am I going wrong?

推荐答案

尝试以下操作

打开config.php,替换

Open config.php and do following replaces

$config['index_page'] = "index.php"

$config['index_page'] = ""

在某些情况下, uri_protocol 无法正常工作。
只需替换

In some cases the default setting for uri_protocol does not work properly. Just replace

$config['uri_protocol'] ="AUTO"

$config['uri_protocol'] = "REQUEST_URI"




HTACCESS

HTACCESS



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

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

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