Saturday, January 31, 2009

Unstable URL Usage


Well, I looked at the urls for project 2 and just about fell out of my chair. I have chosen to use php and well, php and no suffix on the end of urls doesn't mix...or so I thought?!

I tried to fool around with mod_rewrite but I have been having a whale of a time trying to get mod_rewrite to work correctly on this computer. Anyway, tried writing some rules, they didn't seem to be working.

Then, all of a sudden, things just began showing up. I was puzzled. I don't think I did anything?!, I thought to myself. It took me a few minutes but I finally realized that apache is so smart that if I have a file called submit.php and I navigate to www.bla.com/submit that it will run the php file. How cool is that? Really, wickedly awesome cool.

3 comments:

  1. What version of Apache are you using? I had to specifically enable mod_rewrite (and allow certain options and settings to be enabled) before I could get my php pages to work without the .php. Going to /view?imagekey=sldjfhasldhflasdjf didn't work until I did this correctly (I'm also using PHP).

    Perhaps you enabled mod_rewrite without realizing it? If you have rewrite rules they won't work until you turn on the FollowSymlinks option as well.

    ReplyDelete
  2. I was trying to get my Apache to do the same thing, but it wasn't working. I finally found a way to do that and it's as simple as putting one option in the options directive in your httpd.conf file. This is called MultiViews.
    If you look in the .conf file, among others, there will be a section called Directory "/var/www/html" or whatever the path to your directory is.
    The Options directive will most likely be there and will have some options set. All I did was add MultiViews to the list of Option directive and it all magically worked.

    This is what my Options directive looks like now:
    Options Indexes FollowSymLinks Includes ExecCGI MultiViews
    (that is all supposed to be in one line)

    ReplyDelete
  3. The problem is that once it finds your submit.php file, the file it has found is *still* PHP. At least write it in Perl :) (yes, PHP has found the bad side of my zealotry, much as Microsoft has...)

    ReplyDelete