Welcome Guest, Not a member yet? Register   Sign In
Removing index.php and first segment
#1

[eluser]Unknown[/eluser]
Is this even possible? (I can't seem to get it to work.)

Right now I'm trying to remove index.php and the first segment of the url.

when someone goes to http://www.example.com/ they get the main page without the index.php/main/

when they click on my "About Us" link, they go to http://www.example.com/index.php/main/about_us/

I can get rid of the index.php, but I'm having issues for some reason getting the /main part to disappear as well.

I'm sure it's something small that I'm missing, but I can't seem to figure out what. (the current site, which I'm still working on is at haywoods.travislittlechilds.com if that helps at all.

edit: My .htaccess file is:
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php/main|assets|robots\.txt)
RewriteRule ^(.*)$ /index.php/main/$1 [L]

I just get 404's on any of my links, where I should get basic pages (just saying "Menu Page" essentially)
#2

[eluser]Unknown[/eluser]
Code:
RewriteEngine On
RewriteBase /root_CI_folder/
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]

This will work. Put this in the .htaccess file in the root of CI.
#3

[eluser]Unknown[/eluser]
Thank you very much, if you have a minute would you mind explaining it, so I know for future? (I kind of hate just copy pasting code)

From what it looks like it does the same as mine, with the addition of rewriting the system and application links, correct?
#4

[eluser]Bart v B[/eluser]
Dit you also remove the index.php from your application/config/config.php?
Code:
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';

EDIT
my .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>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>
#5

[eluser]Aken[/eluser]
Is every single one of your pages routed through a controller named "main"?

If so, you can use the .htaccess file that Bart v B has shown, and then set up a route to handle the "main" part.

Code:
$routes['(:any)'] = 'main/$1';




Theme © iAndrew 2016 - Forum software by © MyBB