Rewrite Rules in shell script


 
Thread Tools Search this Thread
Top Forums Web Development Rewrite Rules in shell script
# 1  
Old 05-17-2012
Rewrite Rules in shell script

Hi,

Looking for a shell script to redirect the below URLS...

Code:
1) http://domain.site.com/exmp/http://www.example.com/ofxm/supp/un_headfoot?un_head=yes redirects to http://domain.site.com/header.html

2) http://domain.site.com/exmp/http://www.example.com/ofxm/supp/un_headfoot?un_foot=yes redirects to http://domain.site.com/footer.html

Please guide me

Thanks
Wintech

Last edited by Scrutinizer; 05-17-2012 at 06:15 AM.. Reason: code tags instead of quote tags
# 2  
Old 05-17-2012
When you say redirect, do you mean a cgi-script written in sh, why not use Apache's mod_redirect, it is safer and faster and specifically designed for this task?

Such a script would examine the value of $REQUEST_URI and $QUERY_STRING and if they met the criteria sent a 302 response eg
Code:
HTTP/1.1 302 Found 
Location: http://domain.site.com/footer.html

if and egrep should be enough to check the request for either pattern.
# 3  
Old 05-17-2012
Thank Skrynesaver,

If i wanted to use mod_rewrite, Is my below RewriteRule is right? kindly guide me

Code:
1) http://domain.site.com/exmp/http://www.example.com/ofxm/supp/un_headfoot?un_head=yes redirects to http://domain.site.com/header.html
^domain.site.com/exmp/http://www.example.com/ofxm/supp/un_headfoot?un_head=yes$ http://domain.site.com/header.html [L]

2) http://domain.site.com/exmp/http://www.example.com/ofxm/supp/un_headfoot?un_foot=yes redirects to [url]http://domain.site.com/footer.html
^domain.site.com/exmp/http://www.example.com/ofxm/supp/un_headfoot?un_foot=yes$ http://domain.site.com/footer.html [L]


Last edited by Scrutinizer; 05-17-2012 at 08:01 AM.. Reason: quote tags to code tags, removed url tags
# 4  
Old 05-17-2012
The documentation of the module probably offers a more complete response.

But basically the rewrite rule for the URL is a regular expression representing the request string followed the absolute URL of the redirect destination.

However this is done in the conf file appropriate to your httpd version so you really should consult the docs (and not write server configs on the say so of even relatively informed strangers on the net Smilie )
# 5  
Old 05-18-2012
Help needed in Rewrite rules

Hi,

Below is my requirement,

Rewrite Rules is not working - below is my rewrite rules
Quote:
RewriteEngine on
RewriteRule ^domain.site.com/exmp/http://www.example.com/ofxm/supp/un_headfoot?un_head=yes$ http://domain.site.com/header.html [L]

RewriteRule ^domain.site.com/exmp/http://www.example.com/ofxm/supp/un_headfoot?un_foot=yes$ http://domain.site.com/footer.html [L]
Please guide me if im wrong

Regards
Paulwintech

Last edited by fpmurphy; 05-18-2012 at 05:53 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Is Rule 7 of POSIX shell grammar rules written correctly?

The POSIX shell standard grammar rules are at Shell Command Language I am trying to understand Rule 7 and I don't. I think there may be some mistakes there. I am not complaining about the standard; rather, I am concerned that my perception is wrong, and I don't understand something important.... (3 Replies)
Discussion started by: Mark_Galeck
3 Replies

2. Shell Programming and Scripting

Rsync script to rewrite suffix - BASH, awk, sed, perl?

trying to write up a script to put the suffix back. heres what I have but can't get it to do anything :( would like it to be name.date.suffix rsync -zrlpoDtub --suffix=".`date +%Y%m%d%k%M%S`.~" --bwlimit=1024 /mymounts/test1/ /mymounts/test2/ while IFS=. read -r -u 9 -d '' name... (1 Reply)
Discussion started by: jmituzas
1 Replies

3. Shell Programming and Scripting

Shell quoting rules for other languages programmers

I've seen so many times that programmers were confused about shell quoting and white spaces interpretation, that I decided to investigate that problem deeper. And my conclusion is that quoting in shells is very different from other programming languages. Programmers who have bigger experience in... (6 Replies)
Discussion started by: wyderkat
6 Replies

4. Web Development

activecampaign rewrite rules for nginx webserver

Could you help me to write nginx rewite rules for activecampaign at present they only have a apache rewrite rules which to be put in .htaccess cat .htaccess <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / # KB RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME}... (0 Replies)
Discussion started by: unimaxlin
0 Replies

5. Web Development

Apache rewrite rules.

Hi, I am new to Apache but I have requirement as follows. if the url is http://images/data1/templates/ it should redirect to http:/172.20.224.23/templates/ if the url doesn't have "data1/templates" (mean http://images/) it should redirect to http://images:8080/. I tried as below ... (3 Replies)
Discussion started by: sambadamerla
3 Replies

6. Web Development

Rewrite rules to change “link.html?hl=es” to “/es/link.html” etc?

Hey! Does anyone know how to create rewrite rules to change: “link.html?hl=en” to “/en/link.html” “link.html?hl=jp” to “/jp/link.html” “link.html?hl=es” to “/es/link.html” etc? Where "link.html" changes based on the page request? (2 Replies)
Discussion started by: Neo
2 Replies

7. Shell Programming and Scripting

grep help, how do i rewrite this

Thanks , franklin you method worked, i knew i had to use a while loop and getline in there just didnt know the proper order :) Hi everyone, im trying to make the following command line shorter by introducing a script that join up all the grep commands ./new1a < numbers.txt | grep -i -v '^a '... (5 Replies)
Discussion started by: weezybaby
5 Replies
Login or Register to Ask a Question