I have the following rule in .htaccess:
RewriteRule ^order(.*)$ /index.php?p=order&product=$1 [L,NC]
It’s a simplification because later on I want to add order?product=(.*)
I access the website with:
http://website.com/order?product=L0231-03868
but in the $_GET
I’m only getting this:
Array ( [p] => skonfiguruj-zamowienie [product] => )
The product
is empty. What am I missing?
— edit
the moment I add the question mark
RewriteRule ^order?(.*)$ /index.php?p=order&product=$1 [L,NC]
I get 404
2
Answers
With your shown samples please try following htacces rules file. Make sure to keep your htaccess rules file along with index.php file, order folder(3 of them should reside inside root directory). Also clear cache before testing your URLs.
To make it more Generic, as above rules are very samples specific only:
Documentation link:
%{THE_REQUEST}
is being used here, which contains complete request line.order
so there is nothing to capture in(.*)
.QSA
flag to append original query string after rewrite.order
on both sides.Suggested rule:
Because of
QSA
flag, your original query stringproduct=L0231-03868
will be appended top=order
and you will get both parameters in php file.Note about patter
^order?(.*)$
generating404
. Remember that a?
will never be part of URI to be matched usingRewriteRule
hence this pattern containing a?
is guaranteed to always fail.