views:

30

answers:

1

I was coding few php pages to display customer quotations, on rep.php, user can click view details button (POST quoteID as the variable to quotedetails.php?quoteID=Q123456) to view the detailed info about a particular quote.

Then I use .htaccess to make all php pages to html extention and rewrited url from 'quotedetails.php?quoteID=Q123456' to 'quotedetails/Q123456.html', everything works fine on XAMPP, but under WAMP, rewrited url does not display the data on that quotedetail page, i tested by using old url (quotedetails.php?quoteID=Q123456), it works fine, so I guess it must be something wrong with my .htaccess rules as the new html url cannot pass the variable (quoteID).

this is my .htaccess file:

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
A: 

RewriteRule ^quotedetails/(Q[0-9]+).html$ /quotedetails.php?quoteID=$1 [QSA] is the wrong way around isnt it? it should be RewriteRule pattern match, so

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

Hope this helps

Luke

Luke
The first parameter is what is used by the browser and the second parameter is the internal, normally invisible url.
nhnb
thx for reply, but it didnt do the trick. my view detail link url on rep.php is /auma_quotes/quotedetails/$quoteID.html, I want user click that html link, and the server would translate it to quotedetails.php?quoteID=$quoteID, with my original .htaccess it did translate the url but just $quoteID couldnt been pass through.
Patrick
have you tried RewriteRule ^/quotedetails/(Q[0-9]+).html$ /quotedetails.php?quoteID=$1 [QSA] and RewriteRule ^auma_quotes/quotedetails/(Q[0-9]+).html$ /quotedetails.php?quoteID=$1 [QSA]. Sorry about the first answer, I didnt understand you question, I thought you wanted to do the opposite of what you do want to do
Luke
ok, I tried your suggestion, but no change really, that quotedetail page still displays no data... I googled, some say apart from [QSA], %{QUERY_STRING} can be used to capturing variables as well, but I dont know how to use %{QUERY_STRING}.... do you know how? many thanks!
Patrick