[英]Get rid of Index.php in CodeIgniter URLs
How do I remove the "index.php" from my URL? 如何从URL中删除“ index.php”?
Using CI to build a simple MySQL-Php app, I cannot get rid of the "index.php" tag inside the URL: 使用CI构建简单的MySQL-Php应用程序,我无法摆脱URL内的“ index.php”标签:
localhost/CodeIgniter/index.php/Defult_Controller/index
application/.htaccess
and application/cache/.htaccess
: 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>
LoadModule rewrite_module modules/mod_rewrite.so
$config['base_url'] = "http://localhost/CodeIgniter/";
$config['index_page'] = '';
PS: Im using codeIgniter 2.5.1 and xampp 3.2.1 PS:我正在使用codeIgniter 2.5.1和xampp 3.2.1
您需要将.htaccess
放在根文件夹中以删除index.php
, application/.htaccess
可以避免出现目录视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.