How to remove index.php
去掉index.php的方法:首先找到Apache配置文件httpd.conf;然后在该文件中去掉“LoadModule rewrite_module modules/mod_rewrite”前面的“#”号即可。
推荐:《PHP视频教程》
网站当中的index.php往往会让恶意用户得到过多的项目细节信息,去掉网站链接中的index.php,可以大大提高网站的安全性。本文针对Apache服务器下如何配置,才能在访问网站时隐藏index.php。
已有Apache+PHP的服务器环境,并且有一个可以运行的项目。
方法/步骤
找到Apache配置文件httpd.conf,在该文件中去掉LoadModule rewrite_module modules/mod_rewrite.so前面的“#”号,即开启Apache的url重写模式。
将httpd.conf文件里面的所有AllowOverride None都改为AllowOverride All
创建.htaccess文件并放到项目根目录下。
在这个文件里面加:
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [L]
如果项目支持在配置文件中设置项目的url重写模式,需要在项目的配置文件里写
return Array( ‘URL_MODEL’ => ’2′, );
如果不支持在配置文件中设置url重写模式,该步骤可省略。
注意事项
根据Apache的安装目录,在conf文件夹下找到httpd.conf文件。
The above is the detailed content of How to remove index.php. For more information, please follow other related articles on the PHP Chinese website!

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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics



PHP 8's JIT compilation enhances performance by compiling frequently executed code into machine code, benefiting applications with heavy computations and reducing execution times.

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

The article discusses symmetric and asymmetric encryption in PHP, comparing their suitability, performance, and security differences. Symmetric encryption is faster and suited for bulk data, while asymmetric is used for secure key exchange.

The article discusses implementing robust authentication and authorization in PHP to prevent unauthorized access, detailing best practices and recommending security-enhancing tools.

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

Prepared statements in PHP enhance database security and efficiency by preventing SQL injection and improving query performance through compilation and reuse.Character count: 159

Article discusses retrieving data from databases using PHP, covering steps, security measures, optimization techniques, and common errors with solutions.Character count: 159
