有时需要重定向/article/1.html文件到index.php
把.htaccess放在和index.php同一个文件夹内
反向引用中的$1代表目录,$2代表去除.html后缀后的文件名
RewriteEngine on
RewriteRule ^([a-z]+)/([0-9]+).html$ index.php?dir=$1&id=$2 [L]
重写规则匹配到的是请求URL以.htaccess文件夹所在位置的相对路径.
有时需要重定向/article/1.html文件到index.php
把.htaccess放在和index.php同一个文件夹内
反向引用中的$1代表目录,$2代表去除.html后缀后的文件名
RewriteEngine on
RewriteRule ^([a-z]+)/([0-9]+).html$ index.php?dir=$1&id=$2 [L]
重写规则匹配到的是请求URL以.htaccess文件夹所在位置的相对路径.