[SOLVED] Regex with Apache RewriteRule


 
Thread Tools Search this Thread
Top Forums Web Development [SOLVED] Regex with Apache RewriteRule
# 1  
Old 08-04-2011
[SOLVED] Regex with Apache RewriteRule

Hello Folks....

How you doing all ...

Need your assistance with an Regex with apache rewriterule.

This is what am doing...

1. Using Apache webserver as proxy server for multiple tomcats
2. Using IP filter with in apache using RewriteCondition and RewriteRule
3. Trying to specify in RewriteRule using a regex to look for a specific pattern "ZVZZT" and then if matches redirect to a page.

Code:
    RewriteCond %{REMOTE_ADDR} !=192.168.10.2
    RewriteCond %{REMOTE_ADDR} !=192.168.10.5
    RewriteRule /app1/([A-Z_a-z\.?&=]*)(ZVZZT) /var/www/htdocs/index.html [R=301]

It works fine if a new request comes in as /app1/ZVZZT [ it does redirect to index.html as permanant .. no back button works in browser]. However if the request comes in from already bookmarked link such as

Code:
/app1/loginAction.html?method=validateTickerAndRedirect&companyTicker=ZVZZT

In this case my regex doesnt work. Kindly assist.

Highly appreciated!

-Lynx4DBA

---------- Post updated 08-04-11 at 01:49 PM ---------- Previous update was 08-03-11 at 02:21 PM ----------

Guys .. just for information am posting what i did to resolve my problem..

Code:
RewriteCond %{REMOTE_ADDR} !^10\.42\.15\.14$ 
RewriteCond %{REMOTE_ADDR} !^10\.42\.15\.16$ 
RewriteRule /app1/ZVZZT\z /var/www/htdocs/index.html [R=301]
 
RewriteCond %{REMOTE_ADDR} !^10\.42\.15\.14$ 
RewriteCond %{REMOTE_ADDR} !^10\.42\.15\.16$ 
RewriteCond %{QUERY_STRING} ZVZZT 
RewriteRule /app1/([A-Z_a-z\.?&=]*)$   /var/www/htdocs/index.html [R=301] 

These lines took care of my problem...

-Lynx4DBA

Last edited by radoulov; 08-04-2011 at 04:05 PM.. Reason: Classified as solved.
# 2  
Old 08-04-2011
Thanks for updating the thread with the solution.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sendmail K command regex: adding exclusion/negative lookahead to regex -a@MATCH

I'm trying to get some exclusions into our sendmail regular expression for the K command. The following configuration & regex works: LOCAL_CONFIG # Kcheckaddress regex -a@MATCH +<@+?\.++?\.(us|info|to|br|bid|cn|ru) LOCAL_RULESETS SLocal_check_mail # check address against various regex... (0 Replies)
Discussion started by: RobbieTheK
0 Replies

2. Shell Programming and Scripting

Perl, RegEx - Help me to understand the regex!

I am not a big expert in regex and have just little understanding of that language. Could you help me to understand the regular Perl expression: ^(?!if\b|else\b|while\b|)(?:+?\s+){1,6}(+\s*)\(*\) *?(?:^*;?+){0,10}\{ ------ This is regex to select functions from a C/C++ source and defined in... (2 Replies)
Discussion started by: alex_5161
2 Replies

3. Web Development

Apache module development on apache 2.2

Hi, I'm new to developing modules for Apache. I understand the basics now and can develop something simple which allows a 'GET' request to happen, but what I want to do is actually 'POST' information to my site. I know the basic POST Request works and I can see that it is post by looking at... (2 Replies)
Discussion started by: fishman2001
2 Replies

4. Shell Programming and Scripting

[Solved] Inserting a line beginning with regex

I have been trying to insert a line after a regex but I can't do it. Here is the code I am using: cat saved_doc SET type = type1 SET type = STORE = y /vol/san_e1 /vol/san_5 /vol/san_e9 /vol/san_e11 /vol/san_e12 /vol/san_e13 /vol/san_e14 /vol/san_e16 /vol/san_e17 /vol/san_e18... (4 Replies)
Discussion started by: newbie2010
4 Replies

5. Web Development

Simple RewriteRule

I am trying with a simple RewriteRule in apache. Apache is installed in /var/www/folder3 I have a web-app in folder3 and has files index.php, file2.php. My requirement is not to show original php file. That is if index.php is accessed, it should show index.po/index.html If file2.php is... (5 Replies)
Discussion started by: gameboy87
5 Replies

6. UNIX for Dummies Questions & Answers

read regex from ID file, print regex and line below from source file

I have a file of protein sequences with headers (my source file). Based on a list of IDs (which are included in some of the headers), I'd like to print out only the specified sequences, with only the ID as header. In other words, I'd like to search source.txt for the terms in IDs.txt, and print... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

7. Shell Programming and Scripting

Converting perl regex to sed regex

I am having trouble parsing rpm filenames in a shell script.. I found a snippet of perl code that will perform the task but I really don't have time to rewrite the entire script in perl. I cannot for the life of me convert this code into something sed-friendly: if ($rpm =~ /(*)-(*)-(*)\.(.*)/)... (1 Reply)
Discussion started by: suntzu
1 Replies

8. Shell Programming and Scripting

[solved] merging two files and writing to another file- solved

i have two files as file1: 1 2 3 file2: a b c and the output should be: file3: 1~a 2~b 3~c (1 Reply)
Discussion started by: mlpathir
1 Replies

9. Shell Programming and Scripting

perl regex help solved

Hi there I have a list of mac addresses that are in this format 0100237D2136XX 0118A905599EXX 0118A9054E15XX 010003BAF1F3XX 0118A905599EXX 0100237D6522XX 010C53BAF1F3XX 010003BAF1F3XX 010C53BAF1F3XX The 01 is at the beginning has been put on by my software, but the rest is the mac... (0 Replies)
Discussion started by: rethink
0 Replies

10. Web Development

regex in apache Allow from directive

Hi, Does the apache Allow from directive support regular expressions? such as: Allow from ^web11blah\.blah\.blah\.yahoo\.com$ what i want to do: allow access from hosts in the range web1160blah.blah.blah.yahoo.com to web1189blah.blah.blah.yahoo.com notice the 1160 to 1189 range as part... (3 Replies)
Discussion started by: Yogesh Sawant
3 Replies
Login or Register to Ask a Question