Forum OpenACS Q&A: Re: aolserver4 and url rewrite

Collapse
Posted by Dave Denney on
This is kind of what I am trying to do right now.  The objective is to clean up url's so that file extensions aren't important to the user, and incidentally, so that the files can be any format we please.  Basically, I'm shooting to have all the links in "http://mydomain.com/filename" format, and have it then bounce them to "http://mydomain.com/filename.ext" where .ext is the extension of whatever I happen to be using at the time.  Would this work?  Would I run into problems with people providing "http://mydomain.com/directory/" with this?

Sorry about all these questions, but I'm totally new to AOLServer and TCL, and would like to have more information.  From what I've seen/done thus far, Aolserver is extremely powerful, and does just about everything I could ever ask of it.

As a final question, when the script below is gutted and fixed, where would I put it such that it would be executed every time a page is requested?

What I have thus far, pretty bad I know, and I guarantee that there are issues with it:

proc check_for_no_ext {}
{
        set requested_url [ns_conn url]
        if{!regexp [:alnum:]*\.[:alnum:]* requested_url match}
        {

                append new_url $requested_url ".tcl"
                append return_url "http://mydomain.com" $new_url
                ns_returnredirect $new_url
        }

        else
        {
                append return_url "http://mydomain.com" $requested_url
                ns_returnredirect $return_url
        }
}

ns_register_proc GET /* check_for_no_ext