摆脱CodeIgniter URL中的Index.php [英] Get rid of Index.php in CodeIgniter URLs
本文介绍了摆脱CodeIgniter URL中的Index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从URL中删除 index.php?
How do I remove the "index.php" from my URL?
使用CI要构建一个简单的MySQL-Php应用程序,我无法摆脱URL内的 index.php标签:
Using CI to build a simple MySQL-Php app, I cannot get rid of the "index.php" tag inside the URL:
localhost / CodeIgniter / index.php / Defult_Controller / index
application / .htaccess
和 application / cache / .htaccess
:
<IfModule mod_rewrite.c>
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteEngine On
RewriteBase /CodeIgniter/
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
apache.conf
apache.conf
LoadModule rewrite_module modules/mod_rewrite.so
application / config / config.php
application/config/config.php
$config['base_url'] = "http://localhost/CodeIgniter/";
$config['index_page'] = '';
PS:我使用的是codeIgniter 2.5.1和xampp 3.2.1
推荐答案
您需要将 .htaccess
放在根文件夹中才能删除 index.php
, application / .htaccess
是为了避免目录视图。
You need to place your .htaccess
in your root folder to remove index.php
, application/.htaccess
is to avoid directory view.
这篇关于摆脱CodeIgniter URL中的Index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文