Forum Moderators: phranque
Our current architecture is that we have Apache Proxy Server which forwards their requests to the Web Logic Portal Managed Servers. All the business Logic resides on Web Logic Portal. Apache Proxy is just for request forwarding.
Now we require that any request that comes with a URI of /xyz/*/a.htm should be rewritten using the mod_rewrite module to a URI as /test/xyz/*/a.htm : Now we referred the online docuemntation for using this and did the following entries in the httpd.conf file:
-------------------------------------------------------------
RewriteCond %{REQUEST_URI} ^/xyz/(.*)
RewriteRule ^(.*)$ /test$1 [R]
---------------------------------------------------------------
and this worked .. i.e any URL with a pattern /xyz/*/a.htm is getting redirected to /test/xyz/*/a.htm . But there is a problem here and the problem is that we have "[R]" written on second line of httpd.conf file . Just wanted to know what does this signify. We do not want to use this as we presume it is an HTTP redirect , but the functionality fails if we remove "[R]" from the line above . Why is it necessary to use the "[R]" setting . Can we work without this .
Please let us know if there is a better way to achieve the functionality above:
A 301 redirect would use [R=301] instead. Most times that you need a redirect, 301 is the one you need.
A redirect forces the browser to make a new HTTP request for a new URL.
Without the R, and specifying only a local filepath, you get a rewrite.
A rewrite is different to a redirect. The browser doesn't see a URL change. They get what they asked for at the same URL they requested.
RewriteRule ^xyz/(.*) /test/xyz/$1 [L] Add a leading / before xyz if the rule is to be used in httd.conf.
Before the rewrite, make sure you are also doing the standard domain and file canonicalisation stuff (strip index files, redirect non-www to www, etc) otherwise you expose the files at multiple URLs.
You'll also need to redirect calls for /test/xyz(.*) over to http://www.example.com/xyz$1 using a 301 redirect, so that the files cannot be directly accessed via the /test/ folder as a direct URL.
Regards ,
Ninad
See Apache mod_proxy and associated tutorials, as well as looking at all the other server configuration stuff. Configure *only* a reverse proxy -- Enabling a forward proxy is unnecessary, and presents a serious security risk unless many details are attended to.
Jim