Juniper Scott
Juniper Scott

Reputation: 123

How to Redirect Subdirectory to Parent Directory .htaccess

For quite a while, I've been observing the 404 error log file, and I found that from nowhere, the visitors landed in subdirectories containing numbers that don't exist. And there are more than 50% humans. Although the parent directory does exist, instead of getting back to the parent directory, they are seeing another page that I've set for 404 errors (in simple words, they see a 404 error).

For example:

https://www.example.com/crush/1000

In the upper URL, I don't know who referred to this page with an ending of 1000, and it's not on my server. Now this page will redirect you to https://www.example.com/list/ as I set it, instead of seeing the typical 404 error page.

Now what I want to do is redirect any visitor who visits such pages to the parent directory using .htaccess, i.e.

https://www.example.com/crush/

Remember, the value 1000 is not a fixed value; it could be any number, even including points (.) and slashes (/).

A few examples are:

NOTE: I'm using LiteSpeed not Apache.

Your help is highly appreciated.

Upvotes: 0

Views: 59

Answers (0)

Related Questions