.htaccess无法将变量传递给WAMP上的重写页面

时间:2010-06-30 10:15:05

标签: php .htaccess wamp

我编写了几个php页面来显示客户报价,在rep.php上,用户可以点击查看详细信息按钮(POST quoteID作为变量到quotedetails.php?quoteID = Q123456)来查看有关特定报价的详细信息。

然后我使用.htaccess将所有php页面改为html扩展并从'quotedetails.php?quoteID = Q123456'重新编写url到'quotedetails / Q123456.html',一切正常在XAMPP上运行,但是在WAMP下,重写了url不显示该quotedetail页面上的数据,我使用旧的url(quotedetails.php?quoteID = Q123456)测试,它工作正常,所以我想我的.htaccess规则一定是错的,因为新的html url无法通过变量(quoteID)。

这是我的.htaccess文件:

Options +FollowSymlinks
RewriteEngine on

#sideBar.php edit rep link with the styles below, e.g. all,all.html (showing all)
#or reps/$repID,$repName.html
RewriteRule ^reps/all,all.html$ rep.php?repID=all&repName=all [QSA]   
RewriteRule ^reps/([A-Z]+),([A-Za-z\sA-Za-z]+).html$ rep.php?repID=$1&repName=$2 [QSA]
RewriteRule ^reps/([A-Z]+).html$ rep.php?repID=$1 [QSA]

#rep.php including page string, edit pager links in rep.php with following styles,
#\s indicating a white space therefore mod_rewrite can recognise the repName
#e.g. reps/$repID,$repName,$page.html
RewriteRule ^reps/([A-Za-z]+),([A-Za-z\sA-Za-z]+),([0-9]+).html$ rep.php?repID=$1&repName=$2&page=$3 [QSA]


#quotedetails.php rewrite this page url to Q99999.html
#e.g. quotedetails/$quoteID.html
RewriteRule ^quotedetails/(Q[0-9]+).html$ /quotedetails.php?quoteID=$1 [QSA]

#index/addquote/search/viewall/howto page rewrite *.php ---> *.html
RewriteRule ^index.html$ index.php [QSA]   
RewriteRule ^addquote.html$ addquote.php [QSA]   
RewriteRule ^search.html$ search.php [QSA]   
RewriteRule ^viewall.html$ viewall.php [QSA]   
RewriteRule ^customer.html$ customer.php [QSA]   
RewriteRule ^addcustomer.html$ addcustomer.php [QSA] 
RewriteRule ^howto.html$ howto.php [QSA]
RewriteRule ^nice404.html$ nice404.php [QSA]

ErrorDocument 404 /auma_quotes/nice404.html

1 个答案:

答案 0 :(得分:0)

RewriteRule ^quotedetails/(Q[0-9]+).html$ /quotedetails.php?quoteID=$1 [QSA]是错误的方式不是吗?它应该是RewriteRule模式匹配,所以

RewriteRule ^quotedetails.php?quoteID=(Q[0-9]+)$ quotedetails/$1.html [QSA]

希望这有帮助