Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

how do i combile these two rules btw,

RewriteRule (.*)/(.*) $1/consumerDSLWGP/$2 
RewriteRule (.*)/dsl/(.*) $1/consumerDSLWGP/$2 

i.e., a empty context path or a /dsl context path has to be replaced with /consumerDSLWGP. i tried

(.*)/(dsl)?/(.*) 

but aparently even /dsl is getting appended in the URL.

115.241.55.20 - - [22/Dec/2011:10:20:47 --0500] [superclientstg2.sl.ca/sid#8fd3260][rid#9101a88/initial] (2) explicitly forcing redirect with https://superclientstg2.sl.ca/consumerDSLWGP/consumerDSLWGP/consumerDSLWGP/.../dsl
115.241.55.20 - - [22/Dec/2011:10:20:47 --0500] [superclientstg2.sl.ca/sid#8fd3260][rid#9101a88/initial] (1) escaping https://superclientstg2.sl.ca/consumerDSLWGP/.../dsl for redirect
115.241.55.20 - - [22/Dec/2011:10:20:47 --0500] [superclientstg2.sl.ca/sid#8fd3260][rid#9101a88/initial] (1) redirect to https://superclientstg2.sl.ca/consumerDSLWGP/.../dsl [REDIRECT/302]
share|improve this question
add comment

2 Answers

This rewrite should do what you want:

RewriteRule (/dsl)?/redirect.jsp /DSLWGP/dnsredirect.jsp

You may find this cheetsheat helpful.

Update as per the comments below:

RewriteRule (.*)/dsl/(.*) $1/consumerDSLWGP/$2

Anything that is matched inside brackets in the pattern of the rewrite rule can be referenced as $[number] in the replacement where [number] is a number corresponding to the set of brackets you want.

share|improve this answer
    
so /dsl/redirect.jsp will be redirected to /DSLWGP/dnsredirect.jsp and also anythig after redirect.jsp will also be appended after the dnsredirect.jsp? –  user104790 Dec 21 '11 at 15:21
    
no rewritecond required? –  user104790 Dec 21 '11 at 15:27
    
Actually, my original answer isn't quite correct. You don't need the [QSA] flag at all in this case. QSA is only needed when you are adding extra parameters to the query string. I have modified my answer. –  Ladadadada Dec 21 '11 at 15:58
    
hmm.. tried, dosen't seem to work.. i must be missing something. i'm not a apache person, i work on java, i have this application running in my servers which has many entry points.... so all i want to do is, eliminate creating different instance for different context path and redirect all to same instance of app. i.e, URL with https://.../dsl/... has to be redirected to https://../consumerDSLWGP/.. the only difference will be the context path.. the rest has to remain as it is while redirecting... is their a easier way to do it? –  user104790 Dec 21 '11 at 17:20
    
That doesn't match what you wrote in your question. I'll add another rule to my answer for that requirement. –  Ladadadada Dec 21 '11 at 17:28
show 3 more comments

Something like this should work:

RewriteEngine On
RewriteCond %{QUERY_STRING} jsplang=(en|fr){1}
RewriteCond %{REQUEST_URI} !^(/DSLWGP/)
RewriteRule /(dsl/)?redirect\.jsp http://%{HTTP_HOST}/DSLWGP/dnsredirect.jsp?lang=%1

If it doesn't work:

Two hints:

Please try to use the RewriteLog directive: it helps you to track down such problems:

# Trace:
# (!) file gets big quickly, remove in prod environments:
RewriteLog "/web/logs/mywebsite.rewrite.log"
RewriteLogLevel 9
RewriteEngine On

May I ask you to add the rewrite log in your question?


My favorite tool to check for regexp:

http://www.quanetic.com/Regex (don't forget to choose ereg(POSIX) instead of preg(PCRE)!)

share|improve this answer
    
thanks Olivier, i'll try this.... meanwhile, is redirectRule placed before any Alias definations? –  user104790 Dec 21 '11 at 15:19
    
rewriterules are usually after, but i'm not sure. this sounds logical to me that's all ;) –  Olivier Pons Dec 21 '11 at 19:26
    
:) thanks it works ... how do i combile these two rules btw, RewriteRule (.*)/(.*) $1/consumerDSLWGP/$2 RewriteRule (.*)/dsl/(.*) $1/consumerDSLWGP/$2 i.e., a emty ocntext path or a /dsl context path has to be replaced with /consumerDSLWGP. i tried i tried (.*)/(dsl)?/(.*) , but aparently even /dsl is getting appended in the URL. –  user104790 Dec 22 '11 at 10:06
    
Please update your question, add what you're asking now, and don't forget to select your rules and click on "code" button to ident it properly ;) Answer me (= add a comment here to notify me) once it's done I'll do my best to help you (once again!) –  Olivier Pons Dec 22 '11 at 10:45
    
done! did like you said... really need your help!!! –  user104790 Dec 22 '11 at 12:13
show 6 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.