Forum Discussion

Chenco_322726's avatar
Chenco_322726
Icon for Nimbostratus rankNimbostratus
Aug 31, 2017

Redirect Many urls to homepage

Hello , I have a list of many urls on my website which getting 404 error. I want only the list of the urls to redirect to homepage [ not all the pages on website ] found how to do it for a specific links , but is there anyway to do this with data group list so it can be easier just to put the links and not repeat the command 500 times in the irule?

 

Thank you.

 

3 Replies

  • Hello Chenco,

    Create a "String" type data group (in this example dg-404-URIs) add URIs that gets 404 responses status and add the following part to the irule :

    when HTTP_REQUEST {
    
      set uri [HTTP::uri]
      log local0. "DEBUG $uri"
    
    }
    
    when HTTP_RESPONSE { 
      if { [HTTP::status] eq "404" } {
      if { [matchclass dg-404-URIs eq $uri] } {
        HTTP::respond 302 noserver "Location" "https://page.toto.com/" "Connection" "Close"
      }
      }
    }
    

    Hope it helps

    Please mark it as answer if it works

    Regards

  • i think you can change file htaccess in hosting. that is you configure http 404. i do not trying, but you can reseaching google. my website about printing business card, in photobook,before when i setup, i had meet some cases.