You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by ay...@wipro.com on 2014/09/04 10:25:11 UTC

[users@httpd] Issue on Redirection in Apache

Hi,

My apache is successfully configured with invoking 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]
}

Regards
Ayaskant
Wipro Infotech Ltd.







The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

www.wipro.com

Re: [users@httpd] Issue on Redirection in Apache

Posted by Rich Bowen <rb...@rcbowen.com>.
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