codehaven - php snippets - coding help
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: –

    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?