0

I have hosted codeigniter application in apache2.4 with php7.2 docker environment. Not able to resolve routes correctly.

PATH

/var/www/html/apps/sample1

browser PATH

http://localhost:8080/apps/sample1/

working fine but routes controller and actions is not get resolved until i use index.php

http://localhost:8080/apps/sample1/index.php/admin/logn

Correct Expectation

http://localhost:8080/apps/sample1/admin/logn

.htaccess current configuration, Apache mod_rewrite already enabled

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /app/innovative_travel_web/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [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>  
<IfModule mod_php5.c>
  php_value short_open_tag 1
  php_value upload_max_filesize 20M
  php_value post_max_size 20M
  php_value max_execution_time 200
  php_value max_input_time 200
</IfModule>

Kindly please guide me, how can i fix it.

Syed Raza
  • 1,070
  • 3
  • 14
  • 36

3 Answers3

0

1) create htaccess like

RewriteEngine on
RewriteCond $1 !^(index\.php|asset)
RewriteRule ^(.*)$ index.php?/$1 [L]
Options -Indexes

2) in application/config/config.php file

$config['index_page'] = '';
Poonam Navapara
  • 186
  • 1
  • 9
0

Set in config.php

$config['index_page'] = '';

Then your .htaccess You RewriteBase might look like below based on your root folder or just / if the app runs in root folder

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /folder_name/

    RewriteCond $1 !^(index\.php|images|robots\.txt)

    #Removes access to the system folder by users.  
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]

    #This snippet prevents user access to the application folder
    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>
    ErrorDocument 404 /index.php
</IfModule>
theEUG
  • 399
  • 5
  • 18
0

Set in config.php

$config['index_page'] = '';

in .hta

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /apps/sample1/index.php/$1 [L]
</IfModule>

U need to specify the directory too since your path is /var/www/html/apps/sample1 not /var/www/html/

Abhilash Balaji
  • 76
  • 2
  • 14