Forum Moderators: phranque
It's the first time with mod_rewrite module,and I'm really in trouble...
I'm using apache reverse funcytionality:
ProxyPass /irj [web.server.com...]
ProxyPassReverse /irj [reverse.server.com...]
#proxy /logon both ways
ProxyPass /logon [web.server.com...]
ProxyPassReverse /logon [reverse.server.com...]
#proxy /webdynpro both ways
ProxyPass /webdynpro [web.server.com...]
ProxyPassReverse /webdynpro [reverse.server.com...]
Under the path /irj/go/km/docs I would like to allow users just to browse under certain paths like:
/irj/go/km/docs/path1 and /irj/go/km/docs/path2 and forbidden all other paths under /irj/go/km/docs ..
It's possible?
Thanks a lot!
Marco
Options +FollowSymLinks
#
RewriteLog c:/apache/logs/rewrite.log
RewriteLogLevel 3
RewriteEngine on
#
RewriteRule !^/irj/go/km/docs/(path1¦path2)/ - [F]
Change the broken pipe "¦" character to a solid pipe before use; Posting on this forum modifies the pipe characters.
This should return a 403 response to any request NOT to those two subdirectories. Absolutely everything on your site except those two subdirectories should be inaccessible via HTTP.
We're also assuming that mod_rewrite is compiled-in, LoadModule'd, and AddModule'd.
Just to save time if you still have problems, please tell us how you tested (what URLs, using example.com please, you entered), what the results were, and how those results differed from what you expected. What's in the browser window? Anything in the server error log? etc.
Jim
#Enable reverse-proxying
ProxyVia on
ProxyTimeout 900
ProxyRequests Off
ProxyPreserveHost on
ProxyPass /irj [realserver.com...]
ProxyPassReverse /irj [reverse.com...]
The rule
RewriteRule!^/irj/go/km/docs/(path1¦path2)/ - [F]
blocks everything different from /irj/go/km/docs/path1 and /irj/go/km/docs/path2
I need something like:
# if the path is /irj/go/km/docs
RewriteCond %{REQUEST_URI} ^/irj/go/km/docs/$
# block all subpaths except /irj/go/km/docs/path1 and #/irj/go/km/docs/path2
RewriteRule!^/irj/go/km/docs/(path1¦path2)/ - [F]
I tried it but is not working. Probably it is due to reverse proxy settings? Any suggestions?
Thank you
Marco
[edited by: Hulk_hogan at 1:00 pm (utc) on May 23, 2007]
So, you will need to put the code onto the server where that path exists. If that path is proxied to the back-end, then the code needs to go on the back-end server.
Alternately, you could remove the mod_proxy directives implementing the reverse proxy, and instead use the [P] flag of mod_rewrite's RewriteRule to implement the reverse proxy. This would allow conditional reverse-proxying, since you could then use mod_rewrite's RewriteCond directives to make the decision whether to reverse-proxy the request or not.
Jim