Forum Moderators: phranque
I have the following line in my htaccess, which calls a script:
RewriteRule ^([^/]+)/([^/]+)/(.*)$index.php?engine=$1&language=$2&page=$3 [L]
For example, if a url is like lang/fr/test.html, the URL will be: index.php?engine=lang&language=fr&page=test.html
Here is my problem: My original URLs have a query in front of the page name, but Apache ignores those queries and rewrites only the page name.
For example: If a URL is like lang/fr/test.html?search=phone&blog=1, the Apache rewrites it like: index.php?engine=lang&language=fr&page=test.html.
What I want is to generate is to use the query at the end of the page name, like: page=test.html?search=phone&blog=1
Any help appreciated.
If you need to re-format the pre-existing query string in some way (e.g. change the name of the name/value pair), then use a RewriteCond to match part or all of the pre-existing query string (in the Apache %{QUERY_STRING} variable) and to create a back-reference for use in your RewriteRule.
Without [QSA], the new query string replaces the old if a new query string is specified in the substitution URL. If no new query string is specified, then the pre-existing query string is passed through unchanged.
Jim