从 URL 中删除 index.php - Codeigniter 2 [英] Remove index.php From URL - Codeigniter 2

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

问题描述

我无法从 Codeigniter 的 URL 中删除 index.php.我已经使用 Codeigniter 1.7 创建了一些网站,但我使用的 .htaccess 代码在 2 中不起作用.

I am having trouble removing index.php from my URLs in Codeigniter. I've made a few websites with Codeigniter 1.7 and the .htaccess code I used doesn't work in 2.

我试过使用

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index.php|images|robots.txt|css)
RewriteRule ^(.*)$ ./index.php/$1 [L]

</IfModule>

我也试过没有 RewriteBase/in.

I've also tried it without RewriteBase / in.

我已将 $config['uri_protocol'] 更改为 REQUEST_URI 和 QUERY_STRING,什么都没有.

I have changed the $config['uri_protocol'] to REQUEST_URI and QUERY_STRING and nothing.

我已经设置了 $config['index_page'] = "";

I have set $config['index_page'] = "";

文件结构是192.168.0.130/(site)/所以肯定是回到服务器根目录找不到index.php文件.

The file structure is 192.168.0.130/(site)/ so it must be going back to the root of the server and can't find the index.php file.

我制作的所有控制器都可以通过放置 192.168.0.130/(site)/index.php/testcontroller 来访问

All of the controllers I have made can be reached by putting 192.168.0.130/(site)/index.php/testcontroller

谢谢.

抱歉,如果之前有人问过这个问题 - 我已经看过并尝试过我能看到的.

Apologies if this has been asked before - I have looked and tried what I could see.

我还应该补充一点,我将默认文件夹更改为

I should also add that I changed the default folders to be

申请

CI-2.0

index.php

并将 index.php 中的路径更改为正确.

and changed the paths in index.php to be correct.

推荐答案

尝试使用您发布的第一个代码块,而不是/index.php 尝试使用/(site)/index.php (obv 替换 (site) 与任何您的站点文件夹已命名).

Try the first code block you posted, but instead of /index.php try using /(site)/index.php (obv replacing (site) with whatever your site folder is named).

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

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