Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove index.php from codeigniter in UBUNTU [duplicate]

I know this question is being ask already, i tried all those but still unable to remove index.php from url. Here are my details

Ubuntu 12.10
PHP : 5.4.6
Mod_rewrite in on
CI verson: 2.1

.htacess look like:

RewriteEngine On
RewriteBase /projectname

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

I also look at the below link but no luck.. Cannot remove index.php from url CI based site

How to remove "index.php" in codeigniter's path

My "/etc/apache2/sites-available/default" is look like this:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        AllowOverride None 
        </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Any help appreciated!!

like image 907
Suresh Kamrushi Avatar asked May 15 '13 04:05

Suresh Kamrushi


People also ask

What is .htaccess file in CodeIgniter?

htaccess file in CodeIgniter. htaccess is the shortened used for Hypertext Access, which is a powerful configuration file that controls the directory “. htaccess”. It is used by Apache based web servers to control various server features.

Where is .htaccess file located in CodeIgniter?

You should place your . htaccess file at your root directory not Inside the application folder. Show activity on this post. Go to application/config/config.

Where is base URL in CodeIgniter?

The base URL of the site can be configured in application/config/config. php file. It is URL to your CodeIgniter root.


1 Answers

Step 1 :

Add this in htaccess file

<IfModule mod_rewrite.c>
  RewriteEngine On
  #RewriteBase /

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php [QSA,L]
</IfModule>

Step 2 :

Remove index.php in codeigniter config

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

Step 3 :

Allow overriding htaccess in Apache Configuration (Command)

sudo nano /etc/apache2/apache2.conf

and edit the file & change to

AllowOverride All

for www folder

Step 4 :

Enabled apache mod rewrite (Command)

sudo a2enmod rewrite

Step 5 :

Restart Apache (Command)

sudo /etc/init.d/apache2 restart
like image 64
Dino Babu Avatar answered Sep 24 '22 21:09

Dino Babu