php伪静态之APACHE篇_php实例
1.检测Apache是否支持mod_rewrite
通过php提供的phpinfo()函数查看环境配置,通过Ctrl+F查找到“Loaded Modules”,其中列出了所有apache2handler已经开启的模块,如果里面包括“mod_rewrite”,则已经支持,不再需要继续设置。
如果没有开启“mod_rewrite”,则打开目录 您的apache安装目录“/apache/conf/” 下的 httpd.conf 文件,通过Ctrl+F查找到“LoadModule rewrite_module”,将前面的”#”号删除即可。
如果没有查找到,则到“LoadModule” 区域,在最后一行加入“LoadModule rewrite_module modules/mod_rewrite.so”(必选独占一行),然后重启apache服务器即可。
2.让apache服务器支持.htaccess
如何让自己的本地APACHE服务器支持”.htaccess”呢?其实只要简单修改一下apache的httpd.conf设置就可以让 APACHE支 持.htaccess了。打开httpd.conf文件(在那里? APACHE目录的CONF目录里面),用文本编辑器打开后,查找
Options FollowSymLinks
AllowOverride None
改为
Options FollowSymLinks
AllowOverride All
就可以了。
3.建立.htaccess 文件
如果是在windows平台下,刚开始还真不知道怎么建立”.htaccess”文件,因为这个文件实际上没有文件名,仅仅只有扩展名,通过普通方式是无法建立这个文件的,别着急,马上告诉你三种方法:三种方法都是先建立一个htaccess.txt的文本文件(当然,这个文本文件的名字你可以随便取),然后有三种方式给这个文件重命名:
(1)用记事本打开,点击文件–另存为,在文件名窗口输入”.htaccess”,注意是整个绿色部分,也就是包含英文引号,然后点击保存就行了。
(2)进入cmd命令 窗口,通过cd切换当刚建立htaccess.txt文件的文件夹,然后输入命令:rename htaccess.txt .htaccess ,然后点击键盘Enter键即可。
(3)通过ftp连接htaccess.txt所在文件夹,通过ftp软件重命名。
4.rewrite规则学习
我们新建一个.htaccess文件之后,就在里面写入以下内容:
RewriteEngine on #rewriteengine为重写引擎开关on为开启off为关闭
RewriteRule ([0-9]{1,})$ index.php?id=$1
我讲解一下RewriteRule:RewriteRule是重写规则,支持正则表达式的,上面的([0-9]{1,})是指由数字组成的,$是结束标志,说明是以数字结束!
好吧,现在我们可以实现伪静态页面了,写下一下的规则:
RewriteEngine On
RewriteRule ^index.html$ index.php
RewriteRule ^new-(\d+).html$ newxx.php?uid=$1
就可以实现 http://127.0.0.1/index.html 和 http://127.0.0.1/new-1.html

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



Running the H5 project requires the following steps: installing necessary tools such as web server, Node.js, development tools, etc. Build a development environment, create project folders, initialize projects, and write code. Start the development server and run the command using the command line. Preview the project in your browser and enter the development server URL. Publish projects, optimize code, deploy projects, and set up web server configuration.

There are two ways to export XML to PDF: using XSLT and using XML data binding libraries. XSLT: Create an XSLT stylesheet, specify the PDF format to convert XML data using the XSLT processor. XML Data binding library: Import XML Data binding library Create PDF Document object loading XML data export PDF files. Which method is better for PDF files depends on the requirements. XSLT provides flexibility, while the data binding library is simple to implement; for simple conversions, the data binding library is better, and for complex conversions, XSLT is more suitable.

Apache errors can be diagnosed and resolved by viewing log files. 1) View the error.log file, 2) Use the grep command to filter errors in specific domain names, 3) Clean the log files regularly and optimize the configuration, 4) Use monitoring tools to monitor and alert in real time. Through these steps, Apache errors can be effectively diagnosed and resolved.

There are the following ways to generate a pom.xml file: Use Maven Archetype to provide predefined project templates to automatically generate pom.xml files for specific types of projects. Use the Maven Helper plugin to provide commands to generate pom.xml files. Create manually to customize the pom.xml file for the project.

To set character encoding on the server side to solve the garbled Bootstrap Table, you need to follow the following steps: check the server character encoding; edit the server configuration file; set the character encoding to UTF-8; save and restart the server; verify the encoding.

There are many reasons why XAMPP fails to start MySQL, including port conflicts, configuration file errors, insufficient system permissions, service dependency issues, and installation issues. The troubleshooting steps are as follows: 1) Check port conflicts; 2) Check configuration files; 3) Check system permissions; 4) Check service dependencies; 5) Reinstall MySQL. Follow these steps and you can find and resolve issues that cause MySQL startup to fail.

The preview methods of Bootstrap pages are: open the HTML file directly in the browser; automatically refresh the browser using the Live Server plug-in; and build a local server to simulate an online environment.

The key to PHPMyAdmin security defense strategy is: 1. Use the latest version of PHPMyAdmin and regularly update PHP and MySQL; 2. Strictly control access rights, use .htaccess or web server access control; 3. Enable strong password and two-factor authentication; 4. Back up the database regularly; 5. Carefully check the configuration files to avoid exposing sensitive information; 6. Use Web Application Firewall (WAF); 7. Carry out security audits. These measures can effectively reduce the security risks caused by PHPMyAdmin due to improper configuration, over-old version or environmental security risks, and ensure the security of the database.
