I got the pages working fine, so these rules are ok, but what I really want is
that when the user submits the above form to be redirected to http://domain.com/archive/[I][Input Key Here][/I].
I think that your first RewriteRule will “undo” your third (which is ANDed with the second). What in the world were you trying to do with that mod_rewrite code?
Your form code will send the submitted code to (in the same directory) archive/{DirectoryIndex}?key=value - this is different than archive/value AND there is nothing to specify that value is of the form ([a-z0-9]{8}). As this is a default browser action, you can’t control this (at least not without capturing the submit event and redirecting from your script).
IMHO, you really need to change “./archive/” to “done.php” and, if you don’t want the value to be seen in a query string, use the POST method instead.
Yes, of course that can be done - but what script will serve that? I think it’s a matter of semantics but I think you want to accept archive/abc12345 and have it served by archive/{DirectoryIndex}?key=abc12345.
Okay, the ^/? is because I don’t know whether you’re using Apache 1.x or Apache 2.x (this will work for both), I don’t like to make Apache guess at the DirectoryIndex file (you should know it and you should use it - it will remain hidden), I took your example literally (three lowercase characters followed by five digits) and you can use your own name for the “key”.
Something like you do with redirect www.domain.com to domain.com. It takes a RewriteCond and does a RewriteRule with a 301 redirect, but applied to my situation.
Thank you in advance and most of all thank you for your patience dklynn.
Okay, I’m a bit thrown by the use of ;; in the file name AND you, as webmaster, have to create the link to archive/123abcde (mod_rewrite redirects to the “servable” file, ;;done.php with or without the query string).
Remember, though, that the browser will think that it’s in the archive subdirectory so all your relative links will be off a directory level (use the <Base> tag in ;;done.php to correct for that).
Ok, that still not what I want, but thank you for your time and patience.
I believe that I need some %{QUERY_STRING} conditional to check if someone is accessing the ?key=123abcde query string and than redirect the user to /archive/123abcde.
YOU are the webmaster who is generating the links in the way that you want to see them, i.e., archive/123abcde. Unless you have a directory named 123abcde with a DirectoryIndex file, Apache can’t serve that - and you need to create a redirect so that Apache can serve something other than a 404 page. Generally, that’s done (in cases like yours) by parsing the URI and creating a redirection with a query string using the portions of the parsed URI, i.e.
For others, the ? at the end of a redirection will DELETE any pre-existing query string.
Also, ^key=(EVERYTHING or NOTHING)$ merely matches a query string which begins with a key of “key”. It should be key=([^&]+) to capture the value of key at any location in the query string and ONLY the value of key (rather than other keys and their values, too).
MINOR coding “thingie”: WHY capture EVERYTHING then not use it, i.e., RewriteRule ^(.)$ /archive/%1? [R=301,L] discards the $1. The better technique is to use .? rather than ^(.)$ if it’s not going to be used.
Finally, action=“./” is an abuse of the server daemon as it then has to go off looking for the DirectoryIndex. Okay, maybe it does look “prettier” but …
The only thing that I’m “not able” to solve right now, is the action=“./”, and I do care a lot about performance, but since I have the DirectoryIndex ;;index.php defined, probably it wont hurt Apache that bad… I don’t know, just a tought.