I am currently trying to understand how to rewrite URL's, but I am missing several pieces to the puzzle.
I will have a directory stucture similar to the following...
I want /public/index.php to be called first on nearly every url request. The only exceptions will be for requests going to /public/images, /public/css, and /public/js. Index.php will then examine the URL and determine what to do from there. I also need this to work on my local devel box and on the production server without having to manually change little bits of code that are scattered about.
I have looked into using mod_rewrite to get the desired effect, but I would rather use php to make descisions about what the URL is suppose to mean.
Using mod_rewrite, I will have a URL full of GET data, which is not desirable, especially if I am using GET data within my pages to transfer information. And to top that off, the number of arguments in the URL could change easily, so I will have to label each argument generically, and then reinterpret what each variable is referring to when I finally get to my main PHP script. Also, coming up with regular expressions to determine whether or not I am on my local box, and then trimming the url, is something I am not sure I know how to do.
PHP will allow me to resolve absolute paths into relative ones.
'http://localhost/local/mysite/showarticle/sports/112/' will be interpreted as '/showarticle/sports/112/' very easily without mistaking 'local' and 'mysite' as arguments that need to be processed.
And, I wont need to use any GET data to represent the action I want carried through, php will be able to interpret the URL internally without needing to modify the URL into 'http://localhost/local/mysite/public/index.php?' with a bunch of GET data at the end.
Ideally, I would like to set up a handler in apache (through .htaccess only), that calls index.php for any url that doesnt contain a file at the end ('http://localhost/images/pic.jpg' would be ignored). But as far as I know, handlers are only able to call cgi's (this could be bad information though), and I do not have php installed as a cgi.
I would like the handler to just straight up ignore the URL, call index.php, and pass the URL as an argument.
Is there any way to use the PHP method without using CGI's? If not, how hard is it to set up CGI's (never used em)?
If the PHP handler wont work, where do I start in doing a URL rewrite. I am starting to understand regular expressions, and all of the rewrite rules and rewrite conditions, but Im not exactly sure where to begin in parsing the URL and then making sure my index.php ends up with a valid url that it can interpret.
I know it was long, but thanks for pushing through it.