Question

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.

Was it helpful?

Solution 2

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top