-2

I am trying to remove index.php from url(sub-folder) in codeigniter. I am trying with htaccess file but I didn't get the result.

<IfModule mod_rewrite.c> 
    RewriteEngine On
    RewriteBase /
    RewriteCond $1 !^(index\.php) [NC]
    RewriteRule ^(.*)$ /beta/index.php/$1 [L]
</IfModule>

When I remove index.php from url it will work fine but when i was trying to jump using url then it will not working and index.php not remove automatically from the URL.

Thanks in advance.

Abhishek Gurjar
  • 7,426
  • 10
  • 37
  • 45
Maulik Nai
  • 19
  • 2
  • 7

2 Answers2

0

to hide index.php from the URL. Put this code in .htaccess file.

mod_rewrite must be enabled with PHP

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

you may need to add also this depanding on your hosting provider:

 RewriteRule ^(.*)$ index.php?/$1 [L,QSA] 

or by going to application/confing and change this line to :

 //find the below code   
 $config['index_page'] = "index.php" 
 //replace with the below code
 $config['index_page'] = ""
Yahya Ayyoub
  • 322
  • 2
  • 10
0
RewriteEngine On
RewriteRule ^index.php/(.*)$ /$1 [R=302,L]
  • While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. – Vickel Oct 07 '20 at 23:34