CodeIgniter Forums
How to remove index.php from URL in CodeIgniter ec2 elastic Beanstalk - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: How to remove index.php from URL in CodeIgniter ec2 elastic Beanstalk (/showthread.php?tid=79699)



How to remove index.php from URL in CodeIgniter ec2 elastic Beanstalk - gibin - 07-21-2021

How to remove index.php from URL in CodeIgniter ec2 elastic Beanstalk

my configuration file

htaccess 

<IfModule mod_rewrite.c>
    Options -MultiViews

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

config.php

$config['base_url'] = 'http://XXXXXXXXX.elasticbeanstalk.com/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';


RE: How to remove index.php from URL in CodeIgniter ec2 elastic Beanstalk - InsiteFX - 07-21-2021

Add to your .htaccess file where index.php is in public folder.

Code:
    # Remove index.php from URL
    RewriteCond %{HTTP:X-Requested-With}    !^XMLHttpRequest$
    RewriteCond %{THE_REQUEST}              ^[^/]*/index\.php [NC]
    RewriteRule ^index\.php(.*)$            $1 [R=301,NS,L]
.


RE: How to remove index.php from URL in CodeIgniter ec2 elastic Beanstalk - gibin - 07-22-2021

added and getting the same error. actually, I got the default page but get an error while taking any other page.
if I have added 'index.php'/controller name' it will work. I want to make it without index.php

error : "404 Not Found nginx/1.20.0"


RE: How to remove index.php from URL in CodeIgniter ec2 elastic Beanstalk - InsiteFX - 07-22-2021

Code:
## try this one.

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

## if that does not work try this one.

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


Try that, if those do not work then it has to be a server setup issue.


OR try this also.

PHP Code:
// Try changing this to a different protocol.
$config['uri_protocol'] = 'REQUEST_URI'


Let me know if you get it working.


RE: How to remove index.php from URL in CodeIgniter ec2 elastic Beanstalk - gibin - 07-22-2021

I tried but no change same error


RE: How to remove index.php from URL in CodeIgniter ec2 elastic Beanstalk - gibin - 07-22-2021

is it possible to identify the server setup issue


RE: How to remove index.php from URL in CodeIgniter ec2 elastic Beanstalk - gibin - 07-28-2021

(07-21-2021, 08:48 PM)InsiteFX Wrote: Add to your .htaccess file where index.php is in public folder.

Code:
    # Remove index.php from URL
    RewriteCond %{HTTP:X-Requested-With}    !^XMLHttpRequest$
    RewriteCond %{THE_REQUEST}              ^[^/]*/index\.php [NC]
    RewriteRule ^index\.php(.*)$            $1 [R=301,NS,L]










finally got it
created a file in nginx (/etc/nginx/conf.d/elasticbeanstalk/01modrewrite.conf)
code :
location / {

        try_files $uri $uri/ /index.php?$query_string;

        # Remove from everywhere index.php
        if ($request_uri ~* "^(./)index\.php(/?)(.)") {
            return 301 $1$3;
        }
    }
.