Home > Backend Development > PHP Tutorial > How to Remove index.php from URLs in CodeIgniter 2?

How to Remove index.php from URLs in CodeIgniter 2?

Patricia Arquette
Release: 2024-11-24 08:20:10
Original
798 people have browsed it

How to Remove index.php from URLs in CodeIgniter 2?

Removing index.php from URLs in Codeigniter 2

Many developers have encountered difficulties removing index.php from URLs in Codeigniter 2. While solutions from Codeigniter 1.7 may not be applicable, there are specific steps you can take to achieve this.

Solution:

To remove index.php from URLs in Codeigniter 2, try the following:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /(site)/

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/ [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/ [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/ [L]
</IfModule>
Copy after login

Explanation:

This updated code block modifies the RewriteBase directive to include your site folder's name, which is assumed to be "(site)" in this example. By specifying the correct site folder, the server will be directed to the appropriate location to search for the index.php file when requested.

The above is the detailed content of How to Remove index.php from URLs in CodeIgniter 2?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template