Welcome to WebmasterWorld Guest from 184.108.40.206
I want to manually enter all of the redirected pages because none of the URL's are search engine Friendly. Meaning
I may want:
http://www.example.com/productdetail.php?ID=343&Hash=7aea1e538ecda42d48db6474e652e158d0ddba0f to redirect to
and maybe another page:
http://www.example.com/productdetail.php?ID=3333&Hash=7aea1e538ecda42d48db6474e652e158d0ddba0f to redirect to
I will do this line by line because from here on in I will be able to write my Rewrite rule and never have to worry about this again. It is just to correct all the screw ups of there last web company using a crappy CMS system.
The Hash needs to leave forever.
I'm figuring that the RewriteRule would look like:
(I Can do it once of 100 times.)
RewriteRule ^([^/]*)/([^/]*)\.html$ /?ID=$1&NAME=$2 [L]
OR Should I do all of these per each one...
RewriteRule ^([^/]*)/Taxi-Tracker\.html$ /?ID=$1 [L] <-- for Taxi-Tracker Page
RewriteRule ^([^/]*)/Taxi-Cab-Technology\.html$ /?ID=$1 [L] <-- for Taxi Car Technology Page
Note that your statement of the direction of redirection is backwards when compared to your code, and that this is an internal rewrite, not an external redirect. Your code is internally rewriting "friendly" .html URLs to "unfriendly" script filepaths plus query strings.
If your intent is to clean up "unfriendly" URLs listed in search results, then you do need a redirect in addition to the above internal rewrite. However, the code to do this redirection is complicated by the fact that you will have to check to be sure that the "unfriendly" path is being requested directly by a client and not as a result of the internal rewrite function needed to implement the "friendly" URLs. If you don't check for direct client requests before redirecting, then you'll end up with an "infinite" rewrite/redirect loop, because the internal-rewrite rule will rewrite friendly URLs to the unfriendly script file-path, and then the external-redirect rule will redirect that request right back again. This will loop until the server throws an error and gives up or until the browser redirection limit is reached and it gives up.
Because of all the problems -- asymmetrical friendly/unfriendly URLs forcing case-by-case URL-by-URL handling, plus the complications of loop avoidance, you might be happier rewriting only 'friendly' URLs to your script, and then handling all 'unfriendly' URL client requests inside your script.
The advantage is that since the script has database access, it can use one simple function to take an unfriendly client-requested URL, go look up the "Taxi-Tracker" title based on the hash in that requested URL, and generate a 301 redirect to the correct friendly URL -- and all such unfriendly-URL-to-friendly-URL redirects can be handled with just a few lines of code.
You don't need a back-reference to "hash" according to what you've posted above. So remove the inner layer of parentheses from the RewriteCond pattern and drop the undefined %3 reference from the RewriteRule substitution.