Forum Moderators: phranque
I need to apply a rule based on a url path. All urls that begin with /special/(rest of path) must attempt to serve content from a specfic directory. This I have setup and working.
The first hard part is that if the file at the path does not exist, redirect to a different server within the network. This part I cannot get to work.
The second hard part, and maybe the hardest, is that the url in the address bar of the browser must remain the same as typed in.
I've RTFM'd all day, and though certain techniques seem to address certain parts of my problem, I cannot figure out how to complete the solution. Any help is GREATLY appreciated.
This is what I'm currently attempting:
Alias /special/ "C:/offer/pages/"
<Directory "C:/offer/pages/">
AllowOverride None
Order allow,deny
Allow from all
</Directory>
RewriteEngine on
RewriteCond /special/([^\/]+/.*)!-d
RewriteCond /special/([^\/]+/.*)!-f
RewriteRule ^/special/([^\/]+/.*)$ http://localhost:8080/offerengine/special/$1
It only does part one.
Thanks in advance,
Todd
Welcome to WebmasterWorld!
Your RewriteCond syntax is 'misimplemented'... :)
You can't put regex in the left-hand side, and besides, what is that regex supposed to match against? (Rhetorical)
Some variation on the following should work:
EewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/special/([^\/]+/.*)$ http://localhost:8080/offerengine/special/$1 [P,L]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
This looks like it's working for the most part. I'm getting a 403 Forbidden Error, however. If I remove the [P,L] it works, but then the url in the address bar gets rewritten. Is there any way around this?
Thanks again!
[Thu Sep 22 19:25:28 2005] [warn] proxy: No protocol handler was valid for the URL /special/gotrlb/allyreu/. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
My config is now:
Alias /special/ "C:/offer/pages/"
<Directory "C:/offer/pages/">
Options Indexes FollowSymLinks MultiViews IncludesNoExec
AllowOverride None
Order allow,deny
Allow from all
</Directory>
RewriteEngine on
RewriteLog /rewrite.log
RewriteCond %{REQUEST_FILENAME}!-d
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^/special/([^\/]+/.*)$ http://localhost:8080/offerengine/special/$1 [P,L]
#
# Proxy Server directives. Uncomment the following lines to
# enable the proxy server:
#
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
<IfModule mod_proxy.c>
ProxyRequests On
<Proxy *>
Order deny,allow
Deny from all
Allow from all
</Proxy>
# Enable/disable the handling of HTTP/1.1 "Via:" headers.
# ("Full" adds the server version; "Block" removes all outgoing Via: headers)
# Set to one of: Off ¦ On ¦ Full ¦ Block
#
#ProxyVia Full
#
# To enable the cache as well, edit and uncomment the following lines:
# (no cacheing without CacheRoot)
#
#CacheRoot "C:/Program Files/Apache Group/Apache2/proxy"
#CacheSize 5
#CacheGcInterval 4
#CacheMaxExpire 24
#CacheLastModifiedFactor 0.1
#CacheDefaultExpire 1
#NoCache a-domain.com another-domain.edu joes.garage-sale.com
</IfModule>
Does anything seem to be missing?
Thanks again!