1

由于某些原因,在 CI 2.0 中,URLS 不起作用。

http://localhost/myapp/ - will open the default controller (bc it finds index.php)
http://localhost/myapp/index.php/home/ - will open the default controller 
http://localhost/myapp/home/ - will show path not found

我不确定这是 2.0 的问题还是我的配置的特定问题。

我在 Mac OS X Snow Leopard 上运行 Apache 2。

我寻找 .htaccess 解决方案,但找不到 CI 2.0 的任何解决方案。

4

6 回答 6

4

你在apache中有一个重写规则来处理这样的codeigniter吗?见:http ://codeigniter.com/wiki/mod_rewrite/

  • 默认情况下第一个将起作用(默认为 index.php)
  • 秒一个会起作用,因为你将它传递给 index.php
  • 第三个不会没有重写规则。
于 2010-09-17T20:54:07.833 回答
3

真正的问题是,在 Snow Leopard 中,通常位于 /private/etc/apache2/httpd.conf 的实际目录配置现在位于 /private/etc/apache2/users/[USERNAME].conf 默认情况下,FollowSymlinks 和 AllowOverride 被禁用所以你必须去手动修复它,即使它在常规 httpd.conf 中启用

棘手。谢谢大家。否则,您所需要的只是人们已经指出的常规 .htaccess 。

于 2010-09-18T16:43:41.577 回答
1

.htaccessCodeIgniter 1.7 的解决方案也适用于 CodeIgniter 2.0。 .htaccess用于配置独立于 CodeIgniter 的 Apache webserver。

(因此CodeIgniter 手册中的建议配置应该可以正常工作。)

于 2010-09-17T20:53:20.813 回答
0
$ sudo sudo chgrp staff /Library/WebServer/Documents/
$ sudo chmod 775 /Library/WebServer/Documents/

之后,我所有的应用程序都将位于文件夹 /Library/WebServer/Documents/ 下

就像“测试”

/Library/WebServer/Documents/testing

$ echo "Hello World" >> /Library/WebServer/Documents/testing/index.php
http://localhost/testing 
==> it should appear Hello World

现在在“/Library/WebServer/Documents/”文件夹下,您将放置必须添加的 CI 文件夹

.htaccess 

RewriteEngine On
RewriteCond $1 !^(index\.php)
RewriteRule ^(.+)$ index.php?$1 [L]
AddHandler php5-script .php

在你的 CI_Folder/application/config.php

$config['index_page'] = '';

我认为仅此而已!享受!

于 2011-08-18T23:20:25.773 回答
0

你可以在这里找到它。它位于“删除 index.php 文件”标头下方。

删除 index.php 文件

默认情况下,index.php 文件将包含在您的 URL 中:

example.com/index.php/news/article/my_article 您可以使用带有一些简单规则的 .htaccess 文件轻松删除此文件。以下是此类文件的示例,使用“否定”方法重定向除指定项目之外的所有内容:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

在上面的示例中,除 index.php、images 和 robots.txt 之外的任何 HTTP 请求都被视为对 index.php 文件的请求。

于 2013-08-07T04:55:41.850 回答
0

最好的方法是安装 XAMPP,和我一起工作。

只需停止本地 apache 并将您的应用程序放在 htdocs (XAMPP) 中。

您将看到您的应用程序遵循友好的 url。

祝你好运

于 2014-04-08T12:38:44.713 回答