去掉url index.php的方法:首先启用mod_rewrite;然后创建htaccess文件,添加内容为“RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]”即可。
本文操作环境:windows7系统、PHP7.1版,DELL G3电脑
移除 URL 中的 index.php
默认情况下,你的 URL 中会包含 index.php 文件:
步骤:
1:启用mod_rewrite:在Apache下找到conf下的httpd.conf文件,去掉:LoadModule rewrite_module modules/mod_rewrite.so前面的“#”符号;
2:在 根目录下的.htaccess文件中添加如下内容,如果没有.htaccess文件,那么就手动创建一个文件。
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] </IfModule>
如果在Codeigniter根目录下你添加了例如:css,js等文件夹,则要加上一句,如:
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond $1 !^(index\.php|images|css|robots\.txt) RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] </IfModule>
【推荐学习:PHP视频教程】
The above is the detailed content of How to remove url index.php. For more information, please follow other related articles on the PHP Chinese website!

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version
SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

WebStorm Mac version
Useful JavaScript development tools
