I am having an issue with a subdirectory that has many different paths, but on the new website we are no longer using that structure. The old website worked this way:
example.com/photos/photo-1
example.com/photos/photo-2
example.com/photos/photo-3
On our new site we are not using /photos, and my current redirect attempts have not worked
Redirect 301 /photos https://example.com/
ends up redirecting to
example.com/photo-1
example.com/photo-2
example.com/photo-3
Removing the photos subdirectory, but still attempting to access the subdirectory that follow it.
The desired result would be for any attempt to access example.com/photos or example.com/photos/* should redirect to homepage at example.com/
Any help would be appreciated.
2
Answers
This should do it.
This probably is the approach that makes most sense:
It uses the rewriting module which means that has to be loaded into the http server. That is the standard setup, though.
In case it is not all subfolders that should get redirected you can name a pattern instead. This allows for exceptions. For example:
And in case both host are identical for the old and the new "site" you can use an internal redirection to simplify things:
In general you should try to implement such rules in the actual http server’s host configuration. And only use a distributed configuration file instead (".htaccess") if you have no access to the central configuration. Various reasons.