簡體   English   中英

擺脫CodeIgniter URL中的Index.php

[英]Get rid of Index.php in CodeIgniter URLs

如何從URL中刪除“ index.php”?

描述

使用CI構建簡單的MySQL-Php應用程序,我無法擺脫URL內的“ index.php”標簽:

localhost/CodeIgniter/index.php/Defult_Controller/index

的.htaccess

application/.htaccessapplication/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

LoadModule rewrite_module modules/mod_rewrite.so

應用/配置/ config.php中

$config['base_url'] = "http://localhost/CodeIgniter/";
$config['index_page'] = '';

PS:我正在使用codeIgniter 2.5.1和xampp 3.2.1

您需要將.htaccess放在根文件夾中以刪除index.phpapplication/.htaccess可以避免出現目錄視圖。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM