秉承MVC架构的思想,CI中的所有控制器都需要经过单点入口文件index.php(默认)来加载调用。也就是说,在默认情况下,所有CI开发项目的URL都形如以下这种形式:
http://localhost/index.php/welcome很显然,默认情况下,index.php在URL地址段中的存在一定程度上影响了URL的简洁和SEO的进行。我们可以通过下面本文介绍的方法来去掉这个讨厌的Index.php。
你或许已经注意到在CodeIgniter用户手册中,已经存在关于此问题的解决方法。但官方提供的这个.htaccess配置,并不是所有时候都能解决问题。下面经过笔者调试操作步骤供大家分享:
前提:服务器配置使用Apache作为Web服务器。
1、将以下配置信息复制并保存为.htaccess文件(.htaccess文件放置在根目录下,即与application目录同级),
默认情况下,index.php 文件将被包含在你的 URL 中:
example.com/index.php/news/article/my_article
你可以很容易的通过 .htaccess 文件来设置一些简单的规则删除它。
-----------------------------------------------------------------
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L
-----------------------------------------------------------------
注意:如果你的项目不在根目录请把上面这一句改为:RewriteRule ^(.*)$ index.php/$1 [L] 在上面的例子中,可以实现任何非index.php、images 和 robots.txt 的 HTTP 请求都被指向 index.php。
(第一步操作与CI操作手册中相同)
2、修改完成后我们访问CI默认欢迎页面(http://localhost/welcome)时,会报错,错误信息如下:
--------------------------------------------------------------
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, admin@sky00.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
--------------------------------------------------------------------------------------
我看了下这里网站里的所有东西都是这样报错,就是图片和TXT也打不开,然后查看了一下程序发现里面有三个文件.htaccess、httpd.ini、nginx.conf,我想应该是这几个家伙在作怪,首先想到的就是.htaccess这个分布文件,将其删除,果断打开网站了,那么找到原因了,把删除了的找回来,去apache里开启.htaccess就好了,下面是开启方法:
在apache配置文件httpd.conf中找到
Options FollowSymLinks
AllowOverride None
有的版本是这样写的
Options FollowSymLinks ExecCGI Indexes
AllowOverride None
总之不管怎么写,你只需要把下面的
AllowOverride None改为AllowOverride All
然后在找到
LoadModule rewrite_module modules/mod_rewrite.so
把这个前面的“#”号去掉,就是去掉注释,然后重启apache.搞定!

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


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

SublimeText3 Chinese version
Chinese version, very easy to use

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

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.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Mac version
God-level code editing software (SublimeText3)