Forum Moderators: phranque

Message Too Old, No Replies

Apache : Mapping url to application servlet name

Need to map given url to application servlet name

         

patrickng01

3:10 am on Apr 12, 2005 (gmt 0)

10+ Year Member



Hi,

I have an application running on OpenCMS. Unfortunately, OpenCMS sets up such that the Servlet URL is /cms/opencms/...... (ie. eg. http://www.example.com/cms/opencms/......)

It seems like OpenCMS does not allow this to be changed anywhere in its config and properties files.

For security reasons, I do not wish this portion of the url to appear. As such, how can I use Apache to rename this? (eg. http://www.example.com/webapp/..... gets translated to http://www.example.com/cms/opencms/....)

The Redirect directive will makes the url appear on the browser (doesn't solve the security issue). Alias directive is really more to map to a physical file path which in this case is different.

any advice is greatly appreciated.

thanks alot

[edited by: jdMorgan at 4:11 pm (utc) on April 12, 2005]
[edit reason] Examplified. [/edit]

jd01

4:06 am on Apr 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think you are asking...

How can I run [example.com...] but make it look like this [example.com...]
in the users browser.

Is this correct?

patrickng01

5:10 am on Apr 13, 2005 (gmt 0)

10+ Year Member



Yes, you are absolutely right. All responses from OpenCMS of course must be translated back to appear as ..../webapp to the client's browser

thanks

jd01

5:58 am on Apr 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is fairly simple, many of the threads here are covering the exact situation you are asking for in one form or another.

The thing most people try to do is go the wrong way... EG they try to write a rule that changes the 'real' URL to a 'fake' one - can't do it. You must go the other way, so when a user clicks on a 'fake' URL mod_rewrite changes the file that opens to the 'real' one.

This explains it fairly well [webmasterworld.com...]

Your RewriteRule will probably look something like...
RewriteRule ^webapp/(.*) /cms/opencms/$1 [L]

Your variable ending (.*) can be a number of different regular expressions depending on the name structure of your actual files and paths. If they are a set pattern, then you can use a regular expression that will catch that patternEG letters only then .whatever you can use ([a-z]+)\.whatever and change your rule to...

RewriteRule ^webapp/([a-z]+)\.whatever /cms/opencms/$1.whatever [NC,L]

Once you get the concept of what mod_rewrite does, you can probably follow a few of the threads and find the right expression, or set of expressions, for your specific situation. (I don't know the threads well enough to tell you which ones are most applicable.)