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!!!
http://www.test.it/outlet/test-2.html
will be translated to
http://www.test.it/outlet-dett.php?prd=test-2
Check if that file exists.
Anything after and including the character ?
are called the query string, so this is how it goes:
- The server loads
outlet-dett.php
- and passes it the variable named
prd
with the valuetest-2
. - then the PHP script in
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.
精彩评论