0

how to remove index.php

http://103.4.217.199/~xxxx/index.php/menu

to

http://103.4.217.199/~xxxx/menu

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

Not working

Mike Rockétt
  • 8,947
  • 4
  • 45
  • 81
  • This has been asked a few times on stack over flow http://stackoverflow.com/search?q=how+to+remove+index.php+from+url+codeigniter –  Jun 18 '15 at 13:37
  • possible duplicate of [Remove index.php From URL - Codeigniter 2](http://stackoverflow.com/questions/5155333/remove-index-php-from-url-codeigniter-2) – José Luis Jun 18 '15 at 13:43
  • These .htaccess might be able to help you https://github.com/riwakawebsitedesigns/htaccess_for_codeigniter –  Jun 18 '15 at 14:48

3 Answers3

1

Open config.php and do following replacement:

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

to

$config['index_page'] = ""

In some cases the default setting for uri_protocol does not work properly. Just replace:

$config['uri_protocol'] ="AUTO"

with

$config['uri_protocol'] = "REQUEST_URI"

Then use this in your .htaccess file:

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 
Mike Rockétt
  • 8,947
  • 4
  • 45
  • 81
sonam gupta
  • 775
  • 6
  • 17
0

running from an IP address type URL

** -----------------------**

<ifModule mod_headers.c> Header set Access-Control-Allow-Origin: * </ifModule> RewriteEngine on RewriteBase /~xxxx/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^(index\.php|css|js|images|robots\.txt) RewriteRule ^(.*)$ index.php/$1 [L]

0

this is my .htaccess that works on both wamp and live linux server running Centos + Apache and Ubuntu +apache

RewriteEngine on
RewriteCond $1 !^(index\.php|images|assets|robots\.txt)
RewriteRule ^(.*)$ /path-to-code-igniter-directory/index.php/$1 [L]

# Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]

I also made a video on how to do this here

https://www.youtube.com/watch?v=v-4VkR54vLU

(skip to 28:50 to see the .htaccess .I also put it in the description under the video)

hope that helps

Nassim
  • 2,879
  • 2
  • 37
  • 39