Solved

Apache HttpServer redirection with mod_rewrite

Posted on 2006-10-20
6
281 Views
Last Modified: 2010-04-16
Need help with Apache HTTP Server redirection.
I have a URL like this

 http://localhost.domain.com/vehicledirect/vehicle.jsp?direct=true

Now, I need to redirect the user to a URL like this.

 http://localhost.domain.com/dealerdirect/dealer.jsp?direct=true&vehicle=somevehicle

So, there are two changes to the new URL.
1.Update to request URI (replace vehicledirect/vehicle.jsp with dealerdirect/dealer.jsp)
 2.Add a new parameter to query string. (vehicle=somevehicle)

I need a Rewrite rule to perform this operation. I'm using apache httpd.conf file to set this.
Please help.
0
Comment
Question by:bala555
6 Comments
 
LVL 2

Expert Comment

by:mploschiavo
ID: 17778448
what are you trying to do?  link to KBB or something like that?

you probably want to use some similiar syntax like:
from
http://httpd.apache.org/docs/2.0/mod/mod_alias.html

ScriptAlias Directive
Description: Maps a URL to a filesystem location and designates the target as a CGI script
Syntax: ScriptAlias URL-path file-path|directory-path
Context: server config, virtual host
Status: Base
Module: mod_alias

The ScriptAlias directive has the same behavior as the Alias directive, except that in addition it marks the target directory as containing CGI scripts that will be processed by mod_cgi's cgi-script handler. URLs with a case-sensitive (%-decoded) path beginning with URL-path will be mapped to scripts beginning with the second argument, which is a full pathname in the local filesystem.

Example:
ScriptAlias /cgi-bin/ /web/cgi-bin/

A request for http://myserver/cgi-bin/foo would cause the server to run the script /web/cgi-bin/foo. This configuration is essentially equivalent to:

Alias /cgi-bin/ /web/cgi-bin/
<Location /cgi-bin >

SetHandler cgi-script
Options +ExecCGI

</Location>
OR

RedirectMatch Directive
Description: Sends an external redirect based on a regular expression match of the current URL
Syntax: RedirectMatch [status] regex URL
Context: server config, virtual host, directory, .htaccess
Override: FileInfo
Status: Base
Module: mod_alias

This directive is equivalent to Redirect, but makes use of standard regular expressions, instead of simple prefix matching. The supplied regular expression is matched against the URL-path, and if it matches, the server will substitute any parenthesized matches into the given string and use it as a filename. For example, to redirect all GIF files to like-named JPEG files on another server, one might use:

RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg 


============================

good luck....

matthew loschiavo
*advertising removed*
0
 

Author Comment

by:bala555
ID: 17778461
I have gone thru all those materials but could not understand much and here i'm. I really looking for a 'RewriteRule' using 'mod_rewrite' for this scenario.
0
 

Author Comment

by:bala555
ID: 17778762
never mind, i did a little more study and wrote a solution by myself.

Here is the working solution.
**********************************************************************************

RewriteMap text int:unescape
RewriteCond %{QUERY_STRING} ^([a-z]+)=([a-z]+)
RewriteRule ^/vehicledirect/vehicle.jsp$ /${text:dealerdirect/dealer.jsp?%1=%2&vehicle=somevehicle} [L,R]

***********************************************************************************
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 17780059
Post a "request for point refunds" to the Community Suport group
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 17962841
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This is an explanation of a simple data model to help parse a JSON feed
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question