This *should* be an easy question, but for some reason I can not get this working.
Here's what I'm attempting to do: In order to preserve a standard web site organizational structure and promote sharing of resources, I'm doing URL rewriting. I'm attempting two rewrites on the incoming request.
The first rewrite adds a trailing slash to the url when requesting any directory in the site (or anything that is not a document). I was imagining that I’d determine what a directory is and what a document is based on the fact that a document has an extension (i.e. .html, or .jpg, or .pdf). So, if the user requests 'http://www.domain.com/dir' Apache picks that up and does a rewrite to 'http://www.domain.com/dir/'. Similarly, a request for 'http://www.domain.com' would be rewritten to 'http://www.domain.com/'. (This is basically to force good form in http requests.)
The second rewrite will append '/home/index.jsp' to any request for the root of the site - i.e. a request for 'http://www.domain.com/' will rewrite to 'http://www.domain.com/home/index.jsp'.
I have mod_rewrite loading in Apache 2.2 - no problems there. One instance of Apache server is being used to host multiple virtual hosts, and the above behavior will apply to sites hosted on the server.
Now I'm not sure where to put the rewrite code exactly, so for the sake of discovery, I attempted to get this working in just one virtual host first. Here is the code from my vhosts.conf file. It does not work at all. (No url rewriting to /home/index.jsp takes place - at least not that I can see in my browser locator bar.)
<VirtualHost www.domain.org> ServerAdmin webmaster@xxxxxxxxxx DocumentRoot /deploy/var/www/htdocs/domain ServerName www.domain.org ServerPath /domain ErrorLog logs/domain/www.domain.org-error_log CustomLog logs/domain/www.domain.org-access_log common
# list of redirects RewriteEngine on RewriteRule \.org$ \.org/ [R] RewriteRule \.org/$ \.org/home/index.jsp [R]
</VirtualHost>
This example is incomplete because the above behavior will need to work for .org, .com, and .net domains. I read that regular expressions would be the preferred way to handle what I was looking to do, so that’s what I attempted. Also, since the behavior applies to all hosted sites, does the code need to be repeated per each virtual host or can it be moved to another location where it will apply to all hosted sites?
Can someone help me get this url rewriting to work properly so that it will work for all domain types (at least .org, .com, and .net) - and also explain to me where in my conf files the code should appear so that it will apply to all requests? Also, should the rewritten url appear in the browser locator bar and if not, is there a way to make that happen so people can bookmark properly?
Thanks in advance!
Darren |