Home > Backend Development > PHP Tutorial > How Do I Remove 'index.php' from My CodeIgniter URLs?

How Do I Remove 'index.php' from My CodeIgniter URLs?

Patricia Arquette
Release: 2025-01-01 03:48:09
Original
934 people have browsed it

How Do I Remove

Removing "index.php" from CodeIgniter URLs

The "index.php" segment that appears in URLs when using CodeIgniter can be distracting and undesirable. To eliminate this and achieve clean, non-index.php-fied URLs, follow these steps:

1. Create an .htaccess file.

Place an .htaccess file in your root web directory.

2. Add the following code to .htaccess:

Use the following code block in your .htaccess file:

RewriteEngine on
RewriteCond  !^(index\.php|[Javascript / CSS / Image root Folder name(s)]|robots\.txt)
RewriteRule ^(.*)$ /index.php/ [L]
Copy after login

3. Customize the .htaccess file (optional).

If necessary, modify the file to include any specific JavaScript, CSS, or image root folder names that may need to be excluded from the rewrite rule.

Alternative .htaccess Configuration:

You may also use an alternative .htaccess configuration located here: http://snipplr.com/view/5966/codeigniter-htaccess/. This configuration includes additional handling for domain base URLs and may be suitable depending on your specific needs.

The above is the detailed content of How Do I Remove 'index.php' from My CodeIgniter URLs?. 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