php ci去掉index.php的方法:首先打开apache的配置文件;然后在ci的根目录下建立“.htaccess”;最后添加内容“RewriteEngine on RewriteCond $1 !^(index.php)”并保存即可。
推荐:《PHP视频教程》
CodeIgniter去掉url中的index.php
RewriteEngine命令需要rewrite mod的支持
$>cd /etc/apache2/mods-enabled 切换到apache下的mods-enabled目录
$>sudo ln -s ../mods-available/rewrite.load rewrite.load 启用rewrite mod
$>sudo /etc/init.d/apache2 restart 重启apache服务器。 或者在apache的配置文件httpd.conf中将#LoadModule rewrite_module modules/mod_rewrite.so前的#去掉,再重启服务器。
或者
sudo a2enmod rewrite
CodeIgniter去掉url中的index.php
CodeIgniter去掉url中的index.php CI默认中url中带index.php,比如 http://localhost/index.php/blog/comment/1.html 去掉这个index.php步骤:
1.打开apache的配置文件,conf/httpd.conf :
LoadModule rewrite_module modules/mod_rewrite.so
,把该行前的#去掉。
搜索 AllowOverride None(配置文件中有多处),看注释信息,将相关.htaccess的该行信息改为AllowOverride All。
2.在CI的根目录下
即在index.php,system的同级目录下,建立.htaccess,直接建立该文件名的不会成功,可以先建立记事本文件,另存为该名的文件即可。内容如下(CI手册上也有介绍):
RewriteEngine on RewriteCond $1 !^(index.php|images|robots.txt) RewriteRule ^(.*)$ /index.php/$1 [L]
就可以去掉 index.php 了。
要注意 /index.php/$1 要根据你目录(Web 目录,比如 http://www.domain.com/index.php)的实际情况来定,比如网站根目录是 /ci/index.php 则要写成 /ci/index.php/$1
RewriteCond $1 !^(index.php|images|robots.txt) 上面的代码意思是排除某些目录或文件,使得这些目录不会 rewrite 到 index.php 上,这一般用在图片、js、css 等外部资源上。也就是说非 PHP 代码都要排除出去。(这里我排除了 images 目录和 robots.txt 文件,当然 index.php 也应该被排除)
3.
将CI中配置文件(system/application/config/config.php)中$config[‘index_page’] = &index.php&;将$config[‘index_page’] = &&; 。
ok,完成。还要记得重启apache。
The above is the detailed content of How to remove index.php in php ci. For more information, please follow other related articles on the PHP Chinese website!

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Linux new version
SublimeText3 Linux latest version