SAR
SAR

Reputation: 1845

How to configut htaccess file on codeigniter public_html

my file structure is like following:

application
public_html
       .htaccess
       index

application/config/config.php

       here i have set blank my base_url and index page

.htaccess

DirectoryIndex index.php
RewriteEngine on                       
RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA] 

but still if i user index.php her i have use virtual host on httpd.conf

<VirtualHost *:80>

    ServerAdmin webmaster@dab
    DocumentRoot "c:\wamp\www\dab\public_html"

    ServerName dab
    ServerAlias www.dab
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-acces.log" common

    <directory "c:\wamp\www\dab\public_html">
        Options FollowSymlinks
        AllowOverride None
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1
    </directory>
</VirtualHost>

what is the solution for not using index.php on the url

thanks in advance

Upvotes: 0

Views: 1116

Answers (2)

Mark Cameron
Mark Cameron

Reputation: 2369

Make sure you have mod_rewrite module enabled in your apache conf, then try an .htaccess that looks more like this:

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

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

Upvotes: 1

worenga
worenga

Reputation: 5856

Find the following line in your application/config/config.php file

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

Set the variable empty as below.

$config['index_page'] = '';

That's it, it worked for me.

If it doesn't work further try to replace following variable with these parameters ('AUTO', 'PATH_INFO', 'QUERY_STRING', 'REQUEST_URI', and 'ORIG_PATH_INFO') one by one

$config['uri_protocol'] = 'AUTO';

Upvotes: 1

Related Questions