简体   繁体   English

从Codeigniter删除index.php

[英]Removing index.php from codeigniter

As of right now... This is the address that shows up when I run the application (and it's functional). 截至目前...这是我运行该应用程序时显示的地址(该地址正常运行)。

http://localhost:8888/baseline/index.php

If I take away the index.php it also works... 如果我拿走index.php也可以...

http://localhost:8888/baseline/

Running these two URI's is the same as running this function (which is functional). 运行这两个URI与运行此功能(具有功能)相同。

http://localhost:8888/baseline/index.php/RegisterController/index

But if I try and run it without the index.php it's not functional... 但是如果我尝试在没有index.php的情况下运行它,那么它将无法正常工作...

http://localhost:8888/baseline/RegisterController/index

In my code I have 2 .htaccess files... 在我的代码中,我有2个.htaccess文件...

在此处输入图片说明

In the one that is right underneath "views" the code is this... 在“视图”下面的代码中,代码是这样的...

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

In the one underneath "system" the code is this... 在“系统”下面的那个代码是这样的...

AddDefaultCharset UTF-8
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L] 

# my url is http://localhost/arny
#RewriteBase /arny/
# set your own
RewriteBase /

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

This is what my config file looks like... 这是我的配置文件的样子... 在此处输入图片说明

I've tried setting it from 'AUTO' to 'PATH_INFO' and haven't had any luck there. 我尝试将其从“ AUTO”设置为“ PATH_INFO”,但没有任何运气。 There has been some talk about changing things on Apache but I have no idea how to do that. 有人谈论过在Apache上进行更改,但是我不知道该怎么做。

I already checked out the following posts and wasn't able to get this working... 我已经检查了以下帖子,但无法正常工作...

I'm currently running... 我目前正在跑步...

  • Netbeans 7.3.1 Netbeans 7.3.1
  • CodeIgniter + Twitter BootStrap Boilerplate CodeIgniter + Twitter BootStrap样板
  • MAMP 2.2 MAMP 2.2

Definitely let me know what other information I can provide and I'll re-edit the post. 一定要让我知道我还能提供什么其他信息,我将重新编辑该帖子。 I definitely feel like an idiot after wading through these other pieces of documentation and still not being able to get this figured out. 在浏览了其他文档之后,我仍然感觉自己像个白痴,但仍然无法弄清楚这一点。

I've been playing around with it as well. 我也一直在玩它。 This is the one which works for me, and I fear touching it: ;) j/k 这是对我有用的那个,我怕碰它:;)j / k

RewriteEngine On
RewriteRule ^(resources)/(.*) $1/$2 [L]
RewriteRule ^(user_guide)/(.*) $1/$2 [L]
RewriteRule (.*) index.php?$1 [L]

It is located outside the application/system/user_guide directories. 它位于application / system / user_guide目录之外。 Resources is my own public folder, ignore that line. 资源是我自己的公用文件夹,请忽略该行。

I haven't touched the internal .htaccess files. 我没有碰过内部的.htaccess文件。 They're what they were: 他们就是他们:

Deny from all

Hope this helps :) 希望这可以帮助 :)

Edit: Also check if you have the mod_rewrite enabled.. 编辑:还检查是否已启用mod_rewrite。

And this.. Remove index.php in CodeIgniter_2.1.4 而这个.. 删除CodeIgniter_2.1.4中的index.php

Try using this under your system folder. 尝试在系统文件夹下使用它。 This will allow the the extensions that you need passed through. 这将允许您传递所需的扩展名。 ( Style Sheets , Scripts, etc... ) (样式表,脚本等...)

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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM