Redirect to add context root


 
Thread Tools Search this Thread
Top Forums Web Development Redirect to add context root
# 1  
Old 12-23-2010
Redirect to add context root

I have an apache site that is connecting to a backend jboss server using the mod_jk plugin. This jboss server has multiple coldfusion applications deploy'd to it, and each of those applications has it's own apache webserver on the frontend.

The problem I'm running into is when I use a front-end DNS entry. So say the URL is:

http://www.foobar-dev.mydomain.com

In order for me to hit the backend jboss server I have to have the context root added to the request sent to apache:

http://www.foobar-dev.mydomain.com/some/context

I want to use mod_rewrite to make it so i can just type http://www.foobar-dev.mydom.com and apache will add the /some/context to the url.

Hopefully i explained that well enough. All my tries have either failed or caused an infinite redirect.

one attempt as an example
Code:
RewriteCond %{SERVER_NAME} ^(http://www.foobar-dev.mydom.com)$ [NC]
RewriteRule ^(http://www.foobar-dev.mydom.com/some/context)$ [R=301]

# 2  
Old 12-23-2010
Well, your condition cannot be just server name if you rewrite to the same server name. I bet you can condition to full URL of http://www.foobar-dev.mydomain.com/
# 3  
Old 12-27-2010
Got it to work:

Code:
  RewriteCond %{SERVER_NAME}= ^(.*)(foobar-dev\.)
  RewriteCond %{REQUEST_URI} !^/some/context/(.*) 
  RewriteRule ^/(.*) http://foobar-dev.huntington.com/some/context/ [R=301]

# 4  
Old 12-27-2010
  • We have to release it form the loop with a negative? Well, sometimes that is the only way, unless you change the host to a different pseudonym, such as server.foobar-dev, and then what do you do for URL typing users that pop over to http://server.foobar-dev/ ?
  • Does the requestor want rewrite of the whole subtree (not a bad idea, but once in the sub-tree, the sub-tree pages might keep you there, but often this is a way to merge webservers and you do want all).
  • Depending on the exact terms, sometimes it is better to tighten up the left end of the filter, so, assuming egrep regex are operating here, "(^www.|^)(foobar-dev\.).
  • I suppose a URI "/some/context" is taken care of by the all-dirs-end-in-/ rule that redirects to URI "/some/context/".
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Questions related to if in awk context and if without awk context

I wrote this code, questions follow #! /bin/bash -f # Purpose - to show how if syntax is used within an awk clear; ls -l; echo "This will print out the first two columns of the inputted file in this directory"; echo "Enter filename found in this directory"; read input; ... (11 Replies)
Discussion started by: Seth
11 Replies

2. UNIX for Dummies Questions & Answers

How to add path to root user

I am trying to add path for root. In /etc directory there is no .bash_profile file it has only profile file can any one say how to add path for root user ? is it possible to add path in profile file for root user. (18 Replies)
Discussion started by: elango963
18 Replies

3. Solaris

Migration of system having UFS root FS with zones root to ZFS root FS

Hi All After downloading ZFS documentation from oracle site, I am able to successfully migrate UFS root FS without zones to ZFS root FS. But in case of UFS root file system with zones , I am successfully able to migrate global zone to zfs root file system but zone are still in UFS root file... (2 Replies)
Discussion started by: sb200
2 Replies

4. UNIX for Dummies Questions & Answers

Regarding context to add in a file

Hi Folks, I have one query is that I can reach to a location of a file named Integration_Config_3.properties through putty cd /usr/local/pos/jlan/config/byStore/il ls -ltr I can open this file in vi editior also vi Integration_Config_3.properties But now my query is I want to add the... (3 Replies)
Discussion started by: SankalpS
3 Replies

5. Solaris

add PATH as root

Sorry this maybe a dumb one, but I am root and want to add something to my PATH. Is the right place to do it here: /usr/dt/config/dtspcdenv ? If so, after I add it, how do I source it? Neither "source <file>" nor ". <file>" work. How does the above file work... is there another... (5 Replies)
Discussion started by: steve701
5 Replies

6. UNIX for Dummies Questions & Answers

Redirect from the Root?

Hello again, What im trying to do is to redirect output from a cmd, from the root, to a file. But i guess thats illegal. I just wanted to know the file size of all files in my system. So: cd / du -k but i need to ouput this information to a 'sysfile.txt' file, or what... (2 Replies)
Discussion started by: oxoxo
2 Replies

7. Shell Programming and Scripting

keep context in awk

here is a data file. ------------------------------------- KSH, CSH, BASH, PERL, PHP, SED, AWK KSH, CSH, BASH, PERL, PHP, BASH, PERL, PHP, SED, AWK CSH, BASH, PERL, PHP, SED, KSH, CSH, BASH, PERL, PHP, SED, AWK ------------------------------------- My desired output is... (2 Replies)
Discussion started by: VTAWKVT
2 Replies

8. Solaris

trying to add .profile for root

I am trying to add a .profile for root I cd to / do vi .profile and get /var/tmp/ExGXaaqa Read only file system... What does this mean? (4 Replies)
Discussion started by: liven
4 Replies

9. UNIX for Dummies Questions & Answers

Run non-root script as root with non-root environment

All, I want to run a non-root script as the root user with non-root environment variables with crontab. The non-root user would have environment variables for database access such as Oracle or Sybase. The root user does not have the Oracle or Sybase enviroment variables. I thought you could do... (2 Replies)
Discussion started by: bubba112557
2 Replies

10. UNIX for Advanced & Expert Users

Context Switching

I know that this is a relative question but can someone give me an idea of what would be considered a high number of context switches? I am running vmstat and show a cs value of between 5000 and 6000 on a 4 processor system. How can I deduce if this number is high or not? Also, the timeslice... (2 Replies)
Discussion started by: keelba
2 Replies
Login or Register to Ask a Question