Apache rewrite rules.


 
Thread Tools Search this Thread
Top Forums Web Development Apache rewrite rules.
# 1  
Old 10-01-2009
Apache rewrite rules.

Hi,
I am new to Apache but I have requirement as follows.
if the url is http://images/data1/templates/[rest of the url path] it should redirect to http:/172.20.224.23/templates/[rest of the url path]
if the url doesn't have "data1/templates" (mean http://images/[anyuri]) it should redirect to http://images:8080/[rest of the url path].

I tried as below
Code:
RewriteCond %{REQUEST_URI} ^/dm5/Templates/.*
RewriteRule ^/dm5/Templates/(.*) http://172.20.224.23:80/templates/$1 [L]
 RewriteRule ^/(.*) http://images:8080/$1 [L]

It is all the time redirecting to http://images:8080/[rest of the url path].

If i comment out "RewriteRule ^/(.*) http://images:8080/$1 [L] " then i am getting the error "File does not exist: " in htdocs folder.

Please help me how to achieve my requirement.

Thanks
Samba Damerla
# 2  
Old 10-01-2009
Where exactly is your rewrite rule?
# 3  
Old 10-02-2009
May be i didn't understood your question. The below are my rewrite rule i write this in Virtula_host section.

RewriteCond %{REQUEST_URI} ^/dm5/Templates/.*
RewriteRule ^/dm5/Templates/(.*) http://172.20.224.23:80/templates/$1 [L]
RewriteRule ^/(.*) http://images:8080/$1 [L]
# 4  
Old 10-02-2009
For this type of rewrite rules, I recommend you place it in the .htaccess file in the appropriate directory or directories and not in your virtual host configuration.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Web Development

Apache rewrite/redirect parameters explanation

hi what is the meaning of the below code, please explain in details RewriteRule '^/(.*)$1$2/?' (1 Reply)
Discussion started by: raghur77
1 Replies

2. Web Development

Append query string via URL rewrite in apache

Hi, Googled around but I couldn't find anything similar. I'm looking to do the following in apache.. if a user comes into the following URL. http://www.example.com/some/thing.cid?wholebunch_of_stuff_here keep the URL exactly as is BUT add &something at the very end of it. thanks in... (1 Reply)
Discussion started by: kmaq7621
1 Replies

3. Web Development

Rewrite Rules in shell script

Hi, Looking for a shell script to redirect the below URLS... 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... (4 Replies)
Discussion started by: Paulwintech
4 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. UNIX for Advanced & Expert Users

Apache rewrite rule help needed

Hi All, I want to redirect from http://localhost/abc/xyz/def?cc=dk&lc=da to http://localhost/abc/mnc/pdf?cc=dk&lc=da. Please suggest a rewrite rule. (0 Replies)
Discussion started by: jagnikam
0 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. Web Development

APACHE rewrite / redirect URL

Hello. I have scenario where a Client send request to Server1. Server1 send request to Server2. Request are xmlHTTPRequest - need to get data (XML) from Server2 back to client. Trying to use APACHE proxy... Anyone can help? What to download / configure / ...? Thank you for your... (2 Replies)
Discussion started by: ampo
2 Replies

8. Cybersecurity

APACHE rewrite / redirect URL

Hello. I have scenario where a Client send request to Server1. Server1 send request to Server2. Request are xmlHTTPRequest - need to get data (XML) from Server2 back to client. Trying to use APACHE proxy... Anyone can help? What to download / configure / ...? Thank you for your help. (1 Reply)
Discussion started by: ampo
1 Replies

9. UNIX for Advanced & Expert Users

Apache Rewrite help!

I am trying to write RewriteRule on Apache_1.3.26 to get users web page from another server. for example if users tries to get web page on www.somedomain.com/~usersname it will get the web page from www.testdomain.com/~username without redirect and users will not be aware of any redirect... (1 Reply)
Discussion started by: hassan2
1 Replies
Login or Register to Ask a Question