0

I am using CodeIgniter 2.1.1 my site structure is like

mysite/
    application/
        controllers/
            backend/
                welcome.php

            welcome.php

        views/
            backend/
            frontend/

        .htaccess

and I can access backend with

http://localhost/mysite/index.php/backend

but I want

http://localhost/mysite/backend

Similarly for frontend I want

http://localhost/mysite/

In config/config.php I set

$config['base_url'] = '';
$config['index_page'] = '';

and experiment many code in .htaccess the latest one is

<IfModule mod_rewrite.c>
    RewriteEngine On

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

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    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>
1
  • do you have mod_rewrite enabled on your local server? Commented Sep 10, 2012 at 10:23

1 Answer 1

2

Your .htaccessshould be in the root of your site, one level above the applicationfolder.

Sign up to request clarification or add additional context in comments.

6 Comments

I moved but when I write localhost/mysite/backend it showed me localhost main page
@PHPFerrari Did you move it into /mysite/ ?
yes exactly one level above application eg: mysite/ .htaccess application/
Default it was AUTO I replaced with REQUEST_URI but nothing happened
Also see if removing the forward slash before index.php in your .htaccess makes any difference - mine is very similar, but doesn't have the forward slash.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.