I am retooling my URL to be part Pretty URL and part Query String to make it more SEO friendly.
In the past, my URL looked like this…
www.debbie.com/finance/economy/
And my mod_rewrite looked like this…
RewriteRule ^([^/]+)/([^/]+)/$ articles/index-subsection.php?section=$1&subsection=$2 [L]
If someone decides to navigate to a different page, or perform a sort, then the URL above will change to something like this…
www.debbie.com/finance/economy/?page=2&sortname=by-date&sortdir=desc
If I leave my mod_rewrite as it used to be, then I can have this new URL, but the $_GET variables appear to be blank.
How should I adapt my mod_rewrite so it works for either type of URL??
Sincerely,
Debbie
By changing [L] to [L,QSA ]
http://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_qsa
“When the replacement URI contains a query string, the default behavior of RewriteRule is to discard the existing query string, and replace it with the newly generated one. Using the [QSA] flag causes the query strings to be combined.”
Jeff_Mott:
By changing [L] to [L,QSA ]
http://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_qsa
“When the replacement URI contains a query string, the default behavior of RewriteRule is to discard the existing query string, and replace it with the newly generated one. Using the [QSA] flag causes the query strings to be combined.”
You beat me to the punch!
I tried this and it seems to be working…
RewriteRule ^([^/]+)/([^/]+)/$ articles/index-subsection.php?section=$1&subsection=$2 [L,QSA]
Thanks!!
Debbie