Welcome Guest, Not a member yet? Register   Sign In
How to remove index.php from URL in CodeIgniter ec2 elastic Beanstalk
#1

(This post was last modified: 07-21-2021, 11:27 AM by gibin.)

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';
Reply
#2

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]
.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

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"
Reply
#4

(This post was last modified: 07-22-2021, 01:46 AM by InsiteFX.)

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

I tried but no change same error
Reply
#6

is it possible to identify the server setup issue
Reply
#7

(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;
        }
    }
.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB