2010-06-30 103 views
0

我编写了几个php页面来显示客户报价,在rep.php上,用户可以单击查看详细信息按钮(POST quoteID作为变量quotedetails.php?quoteID = Q123456)查看关于特定报价的详细信息。.htaccess无法将变量传递给WAMP上的重写页面

然后,我使用.htaccess将所有的PHP页面制作为html扩展名,并将rewrited url从'quotedetails.php?quoteID = Q123456'改为'quotedetails/Q123456.html',在XAMPP下一切正常,但在WAMP下,rewrited 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 
+0

没关系,我的代码是正确的,它是在WAMP的问题,我重新安装了它,一切工作正常现在,由于所有! – Patrick 2010-06-30 13:12:36

回答

0

RewriteRule ^quotedetails/(Q[0-9]+).html$ /quotedetails.php?quoteID=$1 [QSA]是走错了路周围是不是?它应该是重写规则模式匹配,所以

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

希望这有助于

卢克

+0

第一个参数是浏览器使用的参数,第二个参数是内部的,通常不可见的url。 – 2010-06-30 10:39:43

+0

thx回复,但它没有办法。我的观点详细链接rep.php链接是/auma_quotes/quotedetails/$quoteID.html,我希望用户点击该链接,服务器将它翻译为quotedetails.php?quoteID = $ quoteID,与我的原始.htaccess它没有翻译的网址,但只是$ quoteID不能通过。 – Patrick 2010-06-30 10:44:04

+0

你试过RewriteRule ^/quotedetails /(Q [0-9] +)。html $ /quotedetails.php?quoteID=$1 [QSA]和RewriteRule^$ /quotedetails.php?quoteID=$1 [QSA]。 对不起,第一个答案,我不明白你的问题,我以为你想做你想做的事情的相反 – Luke 2010-06-30 10:52:25