English 中文(简体)
CodeIgniter 2.0 friendly URLs not working on Mac OS X Snow Leopard
原标题:

For some reason in CI 2.0 the URLS do not work.

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

I am not sure if this is a problem with 2.0 or a specific problem with my configuration.

I am running Apache 2 on Mac OS X Snow Leopard.

I looked for .htaccess solution, but couldn t find any for CI 2.0.

最佳回答

The real problem was that in Snow Leopard the actual Directory configuration usually located in /private/etc/apache2/httpd.conf is now located in /private/etc/apache2/users/[USERNAME].conf By default FollowSymlinks and AllowOverride are disabled there so you have to go and fix it manually, even if it is enabled in the regular httpd.conf

Tricky. Thanks everybody. Otherwise all you need is the regular .htaccess as people already pointed out.

问题回答

Do You have a rewrite rule in apache to handle codeigniter like this? see: http://codeigniter.com/wiki/mod_rewrite/

  • The first one by default will work (defaults to index.php)
  • seconds one will work because you pass it to index.php
  • third wont without the rewrite rule.

.htaccess solutions for CodeIgniter 1.7 will also work for CodeIgniter 2.0. .htaccess is used to configure the Apache webserver, which is independent of CodeIgniter.

(The suggested configuration from the CodeIgniter manual should therefore work fine.)

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

After that all my app will be under the folder /Library/WebServer/Documents/

Like testing

/Library/WebServer/Documents/testing

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

now under the folder /Library/WebServer/Documents/ you will place the CI folder you will have to add the

.htaccess 

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

On your CI_Folder/application/config.php

$config[ index_page ] =   ;

And i think that s all! Enjoy!

You can find it here. It s below Removing the index.php file header.

Removing the index.php file

By default, the index.php file will be included in your URLs:

example.com/index.php/news/article/my_article You can easily remove this file by using a .htaccess file with some simple rules. Here is an example of such a file, using the "negative" method in which everything is redirected except the specified items:

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

In the above example, any HTTP request other than those for index.php, images, and robots.txt is treated as a request for your index.php file.

The best way is install the XAMPP, work with me.

just stop the local apache and put your application in htdocs (XAMPP).

You will see your application obeying the friendly urls.

Good luck





相关问题
2 mysql instances in MAC

i recently switched to mac. first and foremost i installed xampp. then for django-python-mysql connectivity, i "somehow" ended up installing a seperate MySQL. now the seperate mysql installation is ...

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Controlling OSX windows

I m trying to control windows of a foreign OSX applications from my application. I d like to 1. move the windows on the screen 2. resize the windows on the screen 3. change the currently active window ...

Switching J2SE versions on Mac OS (SnowLeopard)

My current JDK on Mac OS (10.6) is set to 1.6 and I d like to switch to 1.5. A listing of /System/Library/Frameworks/JavaVM.framework/Versions/ shows: lrwxr-xr-x 1 root wheel 10 Nov 3 18:34 ...

Scrolling inside Vim in Mac s Terminal

I ve been googling around trying to figure out if it s possible to use my mouse wheel to scroll while inside Vim in Mac s Terminal, with no luck. It seems as if only X11 or iTerm support this. Before ...

export to MP3 from quicktime API

A question for Apple,QT programmers. Would like to know if it s possible to export a Movie object to MP3 using the QuickTime API. Preferably the ConvertMovieToFile function. I ve looked at ...

热门标签