Search
Generic filters
Exact matches only
  • Redirect url that contains specific text or directory – .htaccess

    14th February 2020

    Random Coding

    random coding category codehaven

    This is not for WordPress! If you want a way of redirecting if a url contains a directory then take a look here.

    If my website had a directory called dogs (/dogs/) in the URL, and I had 100 pages like this: –

    http://aq.gthex.co.uk:10000/dogs/page1/
    http://aq.gthex.co.uk:10000/dogs/page2/
    http://aq.gthex.co.uk:10000/dogs/page3/

    I would not want to use a plugin to redirect every page manually.
    Therefore a redirect rule that looks for /dogs/ is useful like below.
    Place this code in the .htaccess file in your root directory.

    Was this code snippet helpful?

    Comment on this Code Snippet?