httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rich Bowen <rbo...@rcbowen.com>
Subject Re: [users@httpd] Issue on Redirection in Apache
Date Thu, 04 Sep 2014 15:26:00 GMT

On 09/04/2014 04:25 AM, ayaskanta.praharaj@wipro.com wrote:
>
> Hi,
>
> My apache is successfully configured with invoking 
> http://192.168.17.165:7777/cs <http://192.168.17.165:7777/cs> website
>
> My redirection case :
>
> 1) Whenever the URL: http://192.168.17.165:7777/cs/ is invoked (After 
> '/cs/' there would be nothing) it would be changed to 
> http://192.168.17.165:7777/cs/idcplg?IdcService=GET_DOC_PAGE&Action=GetTemplatePage&Page=HOME_PAGE&Auth=Internet
>
> i.e. http://192.168.17.165:7777/cs changes to 
> http://192.168.17.165:7777/cs/idcplg?IdcService=GET_DOC_PAGE&Action=GetTemplatePage&Page=HOME_PAGE&Auth=Internet
>
> 2) But whetever the same URL is invoked with something after '/cs/' it 
> would remain same.
>
> i.e. http://192.168.17.165:7777/cs/index.html changes to 
> http://192.168.17.165:7777/cs/index.html
>
> For this i have done the follwoing configuration in httpd.conf but it 
> does not work.Please help.
>
> {
>
> RewriteEngine On
> RewriteRule http://192.168.17.165:7777/cs/ 
> http://192.168.17.165:7777/cs/idcplg?IdcService=GET_DOC_PAGE&Action=GetTemplatePage&Page=HOME_PAGE&Auth=Internet

> [R]
> RewriteRule http://192.168.17.165:7777/cs 
> http://192.168.17.165:7777/cs/idcplg?IdcService=GET_DOC_PAGE&Action=GetTemplatePage&Page=HOME_PAGE&Auth=Internet

> [R]
> }

So, there's a couple of problems with this.

1) The first argument to RewriteRule is a regular expression - so, a 
substring match, not a complete string equality.
2) The first argument to RewriteRule matches the URI starting after the 
hostname

So you want something more like:

RewriteRule ^/cs/?$ 
http://192.168.17.165:7777/cs/idcplg?IdcService=GET_DOC_PAGE&Action=GetTemplatePage&Page=HOME_PAGE&Auth=Internet

[R,L]

That should do it.

^/cs/?$ means "starts with /cs, with optionally a slash after that, and 
then ends ($ indicates the end of a string match)

--Rich



-- 
Rich Bowen - rbowen@rcbowen.com - @rbowen
http://apachecon.com/ - @apachecon


Mime
View raw message