Redirect Loop for Apache Rewrite

Discussion in 'Apache' started by ravimsc, May 6, 2010.

  1. #1
    Hi All,

    We have an application using Spring and Hibernate .we have implemented SEO friendly URL for my application usig apache web server.We have configuration httpd.conf under apache where we have writtien all the rules.We are using Linux Environment.

    We are facing the Redirect Loop for very first request other consecutive request its working fine.

    When user is trying to access the www.sample.co.uk/ we need to forward it to /myapps/main.htm?action=getMasterData&id=01

    Please find the below configuration in httpd.conf
    <VirtualHost *:80>
    ServerAdmin admin@www.sample.co.uk
    ServerName www.sample.co.uk
    ServerAlias sample.co.uk

    RewriteRule ^/$ /myapps/main.htm?action=getMasterData&siteId=01&subSiteId=00 [P,R=301,L]

    So when user types www.sample.co.uk its going to Redirect Loop because it si going to infinte loops.

    For time being we have re modified the above rules as below
    RewriteRule ^/$ /myapps/index.jsp [NC,L]

    in index.jsp we are redirecting to /main/

    and we have wrriten another rule for main
    RewriteRule ^/main/?$ /myapps/main.htm?action=getMasterData&siteId=01&subSiteId=00 [P,R=301,L]

    which will get the masterdata and display the main page.

    But its not the right way because for one request we are handling it by two rules.Google Engine will not recognize so we will loose the SEO ranking.

    Please some one have better approch to overcome the Redirect Loop .

    Regards,
    Powli Ravi
     
    ravimsc, May 6, 2010 IP