Welcome Guest, Not a member yet? Register   Sign In
remove index.php from url
#8

1. Create a .htaccess file:

You need to create a .htaccess file in the project’s root directory or CodeIgniter directory. Creating a .htaccess file will allow us to modify our rewrite rules without accessing server configuration files. Because of this reason, .htaccess is critical to our web application’s security thus ensures that the file is hidden. htaccess is an acronym used for Hypertext Access, it is a configuration file that controls the directory “.htaccess”.

After creating the .htaccess file, add the following code to this file.
RewriteEngine On-
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

2. Removing index.php file

Open the config.php file in your text editor and remove index.php from here.

Change:

1
$config['index_page'] = "index.php";
To:

1
$config['index_page'] = '';
But in a few cases, it may happen that the default setting for url_protocol does not work properly. For solving this problem we need to open config.php and

Change:

1
$config['uri_protocol'] = "AUTO";
To:

1
$config['uri_protocol'] = "REQUEST_URI";
Most of the time it is already set to REQUEST_URI, In that case, we don’t need to change it.

3. Enable apache mode rewrite

Now, we will need to activate the mod_rewrite with the help of the following command.

1
$ sudo a2enmod rewrite


4. Restart Apache

Now we need to restart the Apache, to do so we write the following command.

1
$ sudo service apache2 restart
This will activate the module or alert us that the module is already in effect.
Regards
I-Softzone- Web Design Company
If You Have Any Query Regarding Web Design & Software Development Let me know,,, Thanks
Reply


Messages In This Thread
remove index.php from url - by jyoti sudyal - 03-05-2018, 04:59 AM
RE: remove index.php from url - by my_RZ - 03-05-2018, 05:15 AM
RE: remove index.php from url - by jyoti sudyal - 03-05-2018, 05:32 AM
RE: remove index.php from url - by ciadmin - 03-05-2018, 06:59 AM
RE: remove index.php from url - by jyoti sudyal - 03-05-2018, 10:36 PM
RE: remove index.php from url - by Muthusamy - 03-05-2018, 11:06 PM
RE: remove index.php from url - by jyoti sudyal - 03-06-2018, 06:28 AM
RE: remove index.php from url - by isoftzone - 01-07-2021, 04:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB