When I first launched my site, URLs were in the following format:
project.php?projectID=1&pageID=2
A few years ago I modified my .htaccess to rewrite these to use segments, like this:
project/1/2
I updated all internal links to use the segmented format, but this was good because it still supported any external incoming links in the old format.
Now I have switched to CodeIgniter, having my pages render using the segmented format is easy, but I'm struggling to work out how to support the old query-string URLs.
My attempts to support query strings natively in CodeIgniter seem to break the segmented URLs, so it looks like I cannot have both supported simultaneously. Setting up a route in CodeIgniter to redirect a query string to a controller doesn't seem to work. E.g.:
$route['project.php?projectID=(:any)&pageID=(:any)'] = 'home/projectview/$1/$2';
My second thought was to modify the .htaccess directly to redirect the query string to the controller, like so:
(Note I am also using the .htaccess rewrite that eliminates the appearance of index.php in the CI URL)
RewriteRule ^project.php?projectID=(\d*)&pageID=(\d*) project/$1/$2/ [L]
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ index.php/$1 [L]
However this rewrite rule doesn't appear to work either. It redirects to my CodeIgniter 404 without being rewritten, and even by removing the default index.php rule it doesn't redirect, so I'm assuming there is something in my regex/.htaccess formatting here that is incorrect.