我想在我的网站中删除.php
和www
。环顾四周,最后得到重复的变量$1
。
RewriteEngine On
RewriteRule ^articles/([a-zA-Z0-9_-]+)-([0-9]+) article.php?id=$2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteCond %{HTTP_HOST} !^example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
它有效,但有人可以向我解释。
答案 0 :(得分:2)
$1
和$2
(依此类推)不是整个文件的变量。相反,它们是重写规则中对捕获组的引用。 (捕获组是正则表达式中括号内的部分。)