Forum OpenACS Q&A: package name in the url

Collapse
Posted by robert parker on
I can mount a package so that a visitor can reference the pages using this url - http://hostname/packagename/pagename

but is there a way I can set up the site map so that a visitor can use a URL like - http://hostname/pagename (i.e. without the package name even though the pages belong to a package) ?

(obviously I would need to make sure the page names in the package dont clash with the main site page names, such as "/admin", but is it possible ?)

thanks
Robert

Collapse
Posted by Gustaf Neumann on
This can be achieved via a .vuh (virtual url handler) file.
Here is an example for achieving this for xowiki
http://alice.wu-wien.ac.at:8000/xowiki-doc/#package-prefix
You will have to alter this file to be useful for other packages.
Collapse
Posted by robert parker on
Hi Gustaf

Sorry but I'm still not able to get this working. I've read the /doc/tutorial-vuh.html and can see how this works for re-direction within the same package.

Does the request processor scan all vuh files in all packages for a matching page to serve?

Does "http://hostname/admin"; use a .vuh file to serve the page "/packages/acs-subsite/www/admin/index.adp" ? If so which vuh file specifies this redirection?

Do I need to set up a watch so that changes to .vuh files are detected?

Thanks, Robert

Collapse
Posted by Gustaf Neumann on
The magic is in the request processor and is - when looking at the details - quite tricky. The .vuh files are called in situations, where a path could not be resolved by other means (from e.g. files and the site node entries).

use find YOUR_INSTALLATION/openacs-4/packages/acs* -name index.vuh to see, what .vuh files are in use in your installation.

Here is a simple example of an index.vuh file to test cases, when the vuh file is called. Save it under openacs-4/openacs-4/www/index.vuh" and then try "http://hostname/schnabbelbrnft";

util_user_message -message "Hey, you called [ns_conn url]"
if {[ns_conn url] ne "/"} {
  ad_returnredirect /
} else {
 rp_internal_redirect /packages/acs-subsite/www/index.tcl
}

You can redirect to every package you like, as in the xowiki-case to an instance /xowiki.

The .vuh files don't have to be watched, they are sourced upon requests.

Collapse
Posted by Jon Griffin on
One side effect I noticed was that 404 errors & etc. seem to have stopped working. I may have something set wrong, but all my sites now default to the redirected page if any errors occur.

I haven't dug that deep since that isn't bad behavior per se, and in my mind actually better than a crummy error page that people see and leave your site because it is broken.

Collapse
Posted by Steve Manning on
Robert

I do exactly this for Fancydress - http://www.fancydress.com/ is the same as http://www.fancydress.com/shop/ (/shop is were the ecommerce package is mounted).

Its quite straightforward. Assuming that you have a subsite for the root of your site, you simply add an index.vuh file to the /www directory of the acs-subsite package and rename the existing index.tcl and index.adp pair in the same directory.

My index.vuh contains the following:

    set url [ad_conn extra_url]
    set ecommerce_root [acs_package_root_dir ecommerce]
    set file "$ecommerce_root/www/$url"
    
    rp_internal_redirect -absolute_path $file
You have to ensure that no subsite files match your package files (hence renaming the index pair) but otherwise it seems to work fine and has been in production for the last two years.

- Steve

Collapse
Posted by robert parker on
Got it!

Here's what I have in my base /www/index.vuh

rp_internal_redirect /packages/mypackage/www[ad_conn url]

As always, openacs forum members are accurate and helpful.

thanks everyone