0

I have done all the said solutions to remove 'index.php' from the URI. The procedure I took is as below: In .htaccess:

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

In config.php

the base_url is set to

$config['base_url'] = 'https://trawellmate.com/';

Removed index.php from

$config['index_page'] = '';

These are the suggested solutions. But nothing worked. I am using SSL and all non requests are redirected to https://trawellmate.com. Following is the lines added to achieve in .htaccess:

#FORCE NON-WWW REDIRECT
RewriteCond %{HTTPS} off 
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*)$ [NC]
RewriteRule (.*) https://%1%{REQUEST_URI} [L,R=301]

Earlier with non SSL(in development mode in localhost) it was working fine. Since, we are about to go live, a quick help will be deeply appreciated.

Jerry Jones
  • 776
  • 1
  • 13
  • 29
  • Also I have made a permanent redirectrion in 000-default.conf in apache server to redirect all non ssl to https://trawellmate.com Redirect permanent / https://trawellmate.com/ – Jerry Jones Mar 27 '20 at 16:29
  • Follow the steps https://stackoverflow.com/questions/9619831/remove-index-php-from-codeigniter-in-xamp/51351995#51351995 – NomanJaved Mar 27 '20 at 17:36

3 Answers3

0

You may try to use the following rules. It worked for me.

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [OR]
RewriteCond %{HTTP_HOST} ^yourwebsite\.com$ [NC]
RewriteRule ^ https://www.yourwebsite.com%{REQUEST_URI} [R=301,L,NE]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /index\.php(/[^\ ]*)?\ HTTP/ 
RewriteRule ^index\.php(/(.*))?$ yourwebsite.com/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
0

Allow overriding htaccess in Apache Configuration (Command)

sudo nano /etc/apache2/apache2.conf

and edit the file & change to

AllowOverride All
Jerry Jones
  • 776
  • 1
  • 13
  • 29
0

Below .htaccess configuration works for me

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

I've placed the .htacess file in /var/www/html ie. Parallel to application directory

Hope you have enabled mod_rewrite module for apache, Also add below block in virtualhost file(000-default.conf) of apache. Please restart server after changes.

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
Vishal
  • 639
  • 7
  • 32