Welcome Guest, Not a member yet? Register   Sign In
CI + Leopard + htaccess - index.php = Impossible?
#1

[eluser]TheLoops[/eluser]
Did anybody of you manage to get rid of the "index.php" in the URL using htaccess on Mac OS X 10.5 Leopard?

Everything is working fine with my localhost testing server, except the htaccess rewriting.

These are some excerpts from my setup:

etc/apache2/httpd.conf:
Code:
#This is factory default:
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
. . .
#This might not be factory default, not sure, though:
<Directory />
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Deny from all
</Directory>
. . .
#This is factory default:
<Directory "/Library/WebServer/Documents">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

etc/apache2/users/username.conf:
Code:
<directory "/Users/username/Sites">
    Options Indexes MultiViews Includes FollowSymLinks
    AllowOverride All
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
    Allow from localhost    
    #Order allow,deny
    #Allow from all
</directory>

NameVirtualHost *:80

<virtualhost *:80>
    DocumentRoot /Users/username/Sites/website/web_root
    ServerName offline-website
</virtualhost>

/Users/username/Sites/website/web_root/.htaccess:
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    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]

    #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>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

Whenever I remove the "index.php" from the URL I get 404:
Code:
404 Page Not Found
The page you requested was not found.

The site's web root is at:
/Users/username/Sites/website/web_root/

The site's application is at:
/Users/username/Sites/website/application/

The CI system is at:
/Users/username/Sites/system/

What the heck am I doing wrong here?
#2

[eluser]James Gifford[/eluser]
Have you tried using a simpler .htaccess file?

Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

This is how I have mine setup and it works for me in Leopard. Although I don't have all the same settings in my http.conf file.
#3

[eluser]TheLoops[/eluser]
Still no success Confusedhut:
#4

[eluser]Chris Newton[/eluser]
This is currently working for me, using 10.5. I'm also serving the pages with MAMP, but I'm guessing it'd work without it as well.

Code:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [QSA,L]
#5

[eluser]TheLoops[/eluser]
Still no success.

But the mod_rewrite seems to be okay, as it shows a CI-generated 404 message.

It's just that I can't access my controllers properly anymore.
If I add the "index.php" again it works like a charme tough. Bummer… :down:
#6

[eluser]forlackofawittyname[/eluser]
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
The above works for me, I am not using MAMP or XAMMP but am using the default 10.5 install. A few caveats though: I don't have a virtual setup--I just use "localhost" as my hostname.
#7

[eluser]Chris Newton[/eluser]
So, if the HTACCESS is working right... have you set the index file to "" in the config?
#8

[eluser]forlackofawittyname[/eluser]
One other thing that might be worth mentioning--and I'm sorry that I did not do it earlier; I have set my default_controller to point to a controller that I have written. You do this in /application/config/routes.php. mahuti: I still have my index file set to"index.php": $config['base_url'] ="http://localhost/";

$config['index_page'] = "index.php";

$config['uri_protocol'] = "AUTO";
#9

[eluser]GSV Sleeper Service[/eluser]
I had no problems, but I'm not using the 'system' apache, I installed my own using macports.
#10

[eluser]TheLoops[/eluser]
[quote author="mahuti" date="1211278055"]So, if the HTACCESS is working right... have you set the index file to "" in the config?[/quote]I had it still set to "index.php", but even after changing it to "" did not make it work.

[quote author="forlackofawittyname" date="1211285258"]One other thing that might be worth mentioning--and I'm sorry that I did not do it earlier; I have set my default_controller to point to a controller that I have written. You do this in /application/config/routes.php. mahuti: I still have my index file set to"index.php":
Code:
$config['base_url'] ="http://localhost/";
$config['index_page'] = "index.php";
$config['uri_protocol'] = "AUTO";
[/quote]No success either.

[quote author="GSV Sleeper Service" date="1211293883"]I had no problems, but I'm not using the 'system' apache, I installed my own using macports.[/quote]I though, that maybe Apache isn't the bad guy, but something in my CI configuration. But even a fresh install of an un-altered application threw the 404. Confusedhut:




Theme © iAndrew 2016 - Forum software by © MyBB