apache MOD_REWRITE regex help

Status
Not open for further replies.

TheDan666

Ars Tribunus Militum
2,359
Man, I suck at regex. So here is what I need to do with MOD_REWRITE.

If the URL contains a specific leading text AND it doesn't have a file extension then add a default page to the request. Basically this:

Code:
www.site.com/servlet/directory/ ---->  www.site.com/servlet/directory/index.htm

but only if the first part of the URL is /servlet. Also, www.site.com/servlet/directory would be equivalent as the first condition but I think apache adds a / to the request automatically.

Any help would be greatly appreciated.


Thanks,
The Dan
 

TheDan666

Ars Tribunus Militum
2,359
[url=http:/civis/viewtopic.php?p=24497701#p24497701:jw838g6h said:
dredphul[/url]":jw838g6h]You might find the following post useful: https://community.jboss.org/message/115335?_sscc=t

Shows example mod_rewrite and talks about changing the default document settings in web.xml

Thanks for the link. The JBoss didn't work because this servlet serves a bunch of files within various directories...don't ask. It's a bizarre set up. Regardless, I was able to sole the issue with following mod_rewrite directive...after 8 hours of frustration:

Code:
#mod_rewrite for default static servlet
RewriteCond %{REQUEST_URI} ^/servlet
RewriteCond %{REQUEST_URI} !.\.

RewriteRule ^(.*)$  %{REQUEST_URI}\/index\.htm [L,PT]

Thanks again for the help.

--The Dan
 
Status
Not open for further replies.