Forum Discussion

Balasubramaniy2's avatar
Balasubramaniy2
Icon for Nimbostratus rankNimbostratus
Sep 02, 2018

Redirect the /robots.txt request to home page

Hi,

 

below URL not redirecting the /robots.test request to homepage. kindly help to achieve if request comes https://www.test.com/robots.txt then the request need to forward to homepage https://www.test.com.

 

Also tried with policy, but not working

 

when HTTP_REQUEST { if { [string tolower [HTTP::uri]] equals "/robots.ext" } { HTTP::redirect ";; } }

 

1 Reply

  • Hi,

    remove ;;. try this:

    when HTTP_REQUEST { 
    
    if { [string tolower [HTTP::uri]] equals "/robots.ext" } { 
        HTTP::redirect "https://www.test.com"
    } 
    
    }
    

    or

    when HTTP_REQUEST { 
    
    if { [string tolower [HTTP::uri]] starts_with "/robots." } { 
        HTTP::redirect "https://www.test.com"
    } 
    
    }
    

    It will work for sure.

    Regards,