I'm fixing up the URL's of my control panel and want to keep the HTTP queries. The problem is currently with the following URL...
admin/cms/edit?section=exam_sect&page=exam_page
Using...
RewriteRule ^(.*)$ index.php?q=$1 [L]
print_r($_GET);
I get...
Array ([q] => cms/edit)
When I want...
Array ([section] => exam_sect [page] => exam_page)
---------------
So I came across this example...
RewriteRule ^(.*)/(.*)/(.*)/(.*)$ shop.cgi?$1=$2&$3=$4
This rule rewrites URL:
< http://www.example.com/cat/cars/product/bmw >
into:
< http://www.example.com/shop.cgi?cat=cars&product=bmw >
That repetition makes it very easy to understand how variables are assigned (math books in grade school did the opposite making it difficult to find patterns with helpful repetition).
So for a while I experimented and somehow came up with the following
that works...
RewriteRule ^(.*)/(.*)$ index.php
So now this URL...
admin/cms/edit?section=exam_sect&page=exam_page
Generates this array with print_r($_GET);...
Array ([section] => exam_sect [page] => exam_page)
For what I need at the moment at least it works though I'm a bit apprehensive since I'm not using ? and $1 at the end of the line nor in the middle have I (at least consciously) made a regular expression for ? (which I think might be \? to escape the question mark in the URL) to retain the HTTP query. Am I not far off, spot on or is this overly coincidental that this works? I understand things best with repetition (even if the need that sparked the question does not require it). In example with JavaScript years ago I saw someone use .parent.parent.parent which led me to figuring out you could access a nested frame using .parent.parent.
- John