url去掉index.php的方法:首先启用“mod_rewrite”;然后在根目录下的“.htaccess”文件中添加内容为“RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]”即可。

推荐:《PHP视频教程》
url去掉index.php的方法:
移除 URL 中的 index.php
默认情况下,你的 URL 中会包含 index.php 文件:
立即学习“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>以上就是url怎么去掉index.php的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号