CodeIgniter 2.0友好的URL不适用于Mac OS X Snow Leopard

时间:2010-09-17 20:42:54

标签: macos codeigniter apache2 codeigniter-2

由于CI 2.0中的某些原因,URL无效。

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。

6 个答案:

答案 0 :(得分:4)

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

  • 默认情况下第一个将起作用(默认为index.php)
  • 秒将会有效,因为您将其传递给index.php
  • 第三个不会没有重写规则。

答案 1 :(得分:3)

真正的问题是,在Snow Leopard中,通常位于/private/etc/apache2/httpd.conf中的实际目录配置现在位于/private/etc/apache2/users/[USERNAME].conf中默认为FollowSymlinks和AllowOverride在那里被禁用,因此您必须手动修复它,即使它在常规httpd.conf中已启用

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

答案 2 :(得分:1)

CodeIgniter 1.7的

.htaccess解决方案也适用于CodeIgniter 2.0。 .htaccess用于配置Apache Web服务器,它独立于CodeIgniter。

CodeIgniter manual建议的配置应该可以正常工作。)

答案 3 :(得分:0)

$ sudo sudo chgrp staff /Library/WebServer/Documents/
$ sudo chmod 775 /Library/WebServer/Documents/

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

喜欢'测试'

/库/ Web服务器/文档/测试

$ 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'] = '';

我认为就是这样!享受!

答案 4 :(得分:0)

你可以找到它here。 它位于“删除index.php文件”标题下面。

  

删除index.php文件

     

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

     

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之外的任何HTTP请求,   images和robots.txt被视为对index.php的请求   文件。

答案 5 :(得分:0)

最好的方法是安装XAMPP,与我合作。

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

您将看到您的应用程序遵守友好的网址。

祝你好运