我有这个htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.test\.com$ [NC]
RewriteRule ^(.*)$ http://www.test.com/$1 [R=301,L]
RewriteRule ^home.html$ index__.php [L]
RewriteRule ^prodotti.html$ prodotti.php [L]
RewriteRule ^azienda.html$ azienda.php [L]
RewriteRule ^news.html$ news.php [L]
RewriteRule ^outlet.html$ outlet.php [L]
RewriteRule ^contatti.html$ contatti.php [L]
RewriteRule ^news-(.*).html$ news.php?id=$1 [L]
RewriteRule ^arr.html$ prodotti-cat.php?cat=a [L]
RewriteRule ^sed.html$ prodotti-cat.php?cat=s [L]
RewriteRule ^par.html$ prodotti-cat.php?cat=p [L]
RewriteRule ^cont.html$ prodotti-cat.php?cat=c [L]
RewriteRule ^comp.html$ prodotti-cat.php?cat=co [L]
RewriteRule ^outlet/([a-zA-Z0-9_-]+).html$ outlet-dett.php?prd=$1 [L]
RewriteRule ^(.*)/(.*)/$ prodotti-cat.php?cat=$1&f=$2 [L]
RewriteRule ^(.*)/(.*).html$ prodotti-dett.php?cat=$1&prd=$2 [L]
如果我在浏览器中写http://www.test.it/outlet/test-2.html,我就找不到...... 为什么??? 帮助!
答案 0 :(得分:0)
http://www.test.it/outlet/test-2.html
将被翻译为
http://www.test.it/outlet-dett.php?prd=test-2
检查该文件是否存在。
字符?
之后的所有内容都被称为查询字符串,所以这就是它:
outlet-dett.php
prd
的变量传递给值test-2
。outlet-dett.php
中的PHP脚本根据prd
的值显示数据。重写规则中的$1
称为后退参考。它引用了您的RegEx中第一个括号之间的匹配。