Welcome Guest, Not a member yet? Register   Sign In
need help with removing index.php
#1

[eluser]CI705[/eluser]
hi all,
I am really struggling with the removal of index.php for hours.
I have been following the steps in http://codeigniter.com/wiki/mod_rewrite/ (except step4 coz i don't really know where to chagne it) but with no luck.

i am using
Quote:debian squeeze
apache 2.2
mysql 5.1
php 5.3

here is the structure in the www folder
Quote:/var/www
`-- CI
|-- application
|-- images
|-- index.php
|-- license.txt
|-- style
|-- system
`-- user_guide
and the .htaccess, which i put it inside the CI folder as well
Quote:<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /CI/

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
and this is the httpd.conf
Quote:#SeverName 127.0.0.1

here is the config.php
Quote:$config['base_url']= 'http://127.0.0.1/CI';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
I can only access the http://127.0.0.1/CI/index.php/welcome but not http://127.0.0.1/CI/welcome
I am really frustrated on this problem and i can't solve it myself.
thanks for any help.
#2

[eluser]Vlad Balmos[/eluser]
change
Code:
RewriteRule ^(.*)$ index.php?/$1 [L]

to this:
Code:
RewriteRule ^(.*)$ /CI/index.php/$1 [L]

and see what happens
#3

[eluser]CI705[/eluser]
[quote author="Vlad Balmos" date="1311858900"]change
Code:
RewriteRule ^(.*)$ index.php?/$1 [L]

to this:
Code:
RewriteRule ^(.*)$ /CI/index.php/$1 [L]

and see what happens[/quote]
thanks for the reply
i tried
Code:
<IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /CI/

      RewriteCond %{REQUEST_URI} ^system.*
      RewriteRule ^(.*)$ /index.php?/$1 [L]
    
      RewriteCond %{REQUEST_URI} ^application.*
      RewriteRule ^(.*)$ /index.php?/$1 [L]

      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ /CI/index.php?/$1 [L]
    </IfModule>

    <IfModule !mod_rewrite.c>
      ErrorDocument 404 /index.php
    </IfModule>
but i still got the error
Code:
Not Found

The requested URL /CI/welcome was not found on this server.
Apache/2.2.16 (Debian) Server at 127.0.0.1 Port 80
#4

[eluser]Vlad Balmos[/eluser]
Ok, try this instead:

Remove the following from the .htacces file:
Code:
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
    
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

and change the uri_protocol to 'auto' in your config file. Maybe the server doesn't populate the Request_uri variable.

if that still doesn't work. Create a virtual host in apache, for example www.localsite.loc (read the apache docs for this), after that add the following lines in your /etc/hosts file:
Code:
127.0.0.1 localsite.loc
127.0.0.1 www.localsite.loc

restart the webserver, modify the base_url in config.php to point to www.localsite.loc
and finally replace .htaccess with this:

Code:
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} ^localsite.loc [NC]
RewriteRule ^(.*)$ http://www.localsite.loc/$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?/$1 [L]
#5

[eluser]CI705[/eluser]
thanks for the help Vlad Balmos.
I have figured out what the problem is. It is the step 4 from the wiki which I didn't follow.
I am writing it down so it may help others and saving their hours of time.
edit /etc/apache2/sites-available/default
Code:
DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride [color=red]FileInfo[/color]
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
if you get any internal server error, just follow the instructions in the wiki
cheers, i am so happy now, thanks for the help again.
#6

[eluser]Vlad Balmos[/eluser]
glad you figured it out.
Best of luck!




Theme © iAndrew 2016 - Forum software by © MyBB