1、什么是伪静态?php
动态页面假装成静态页面显示html
2、为何使用伪静态?编辑器
能够提升SEO优化ide
精简URL地址栏:index.php?id=1 ---> index-1.html优化
3、何时使用伪静态?网站
网站上线spa
4、如何实现伪静态?htm
①在Apache配置文件 httpd.conf 中打开:it
LoadModule rewrite_module modules/mod_rewrite.somodule
全部 AllowOverride none 所有改为 AllowOverride all
重启Apache
②在网站的根目录编写伪静态的规则:
利用编辑器在网站根目录建立文件名为“.htaccess”的文件,不能直接在系统中新建该文件,会显示文件名不正确
.htaccess文件的内容:
RewriteEngine On
RewriteRule index.html index.php
#RewriteRule index-1-2.html index.php?id=1&page=2
RewriteRule index-(\d+)-(\d+).html index.php?id=$1&page=$2
规则的编写是能够使用正则匹配的