remove index.php from url |
How can i remove index.php from url
(03-05-2018, 04:59 AM)jyoti sudyal Wrote: How can i remove index.php from url https://www.codeigniter.com/user_guide/g...x-php-file
"https://www.codeigniter.com/user_guide/g...x-php-file"
i have tried this already but its not working at my end.
The thread was started in the CI2 subforum, suggesting that the answer might be in https://www.codeigniter.com/userguide2/g.../urls.html
As i mentioned above i have tried this already but this is not working for me.
.htaccess file :: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] config file :: $config['index_page'] = 'index.php'; $config['uri_protocol'] = 'REQUEST_URI';
If your Apache server has mod_rewrite enabled, you can easily remove this file by using a .htaccess file with some simple rules. Here is an example of such a file, using the “negative” method in which everything is redirected except the specified items:
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] Same situation happens to me. I have change the code in htaccess file. Please check with this. Hope it will work for you also. If it is not work check Please let us know your url is a Https or Http.
mod_rewrite is enabled by default on godaddy's server and my url is http.
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
Code: <IfModule mod_rewrite.c>
Set line 43 of app/Config/App.php to
public string $indexPage = ''; // = 'index.php'; CodeIgniter Wizard (CRUD code generator for Mac) instantly scaffolds Bootstrap-based web applications with an administrative interface (admin templates include Bootstrap5) |
Welcome Guest, Not a member yet? Register Sign In |