Htaccess url 重写帮助
我有这个 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 我找不到... 为什么??? 帮助!!!
I have this 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]
If i write in my browser http://www.test.it/outlet/test-2.html i get NOT FOUND...
Why???
Help!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
http://www.test.it/outlet/test-2.html
将被翻译为检查该文件是否存在。
在字符
?
之后并包括字符?
的任何内容都称为查询字符串,因此情况如下:outlet-dett.php
prd
且值为test-2
的变量。outlet-dett.php
中的 PHP 脚本根据prd
的值显示数据。重写规则中的
$1
称为反向引用。它引用正则表达式中第一个括号之间的匹配。http://www.test.it/outlet/test-2.html
will be translated toCheck if that file exists.
Anything after and including the character
?
are called the query string, so this is how it goes:outlet-dett.php
prd
with the valuetest-2
.outlet-dett.php
displays the data depending on the value ofprd
.The
$1
in your rewrite rule is called a back reference. It references the match between the first parenthesis in your RegEx.