I am trying to simulate the permalink structure of a previous version of my site using Redirect and RedirectMatch rules in my .htaccess file.
I have different rules that I would to apply to different paths from my old site. Some directories have no analogue and I want them to redirect to a single location. Some directories contain many items (thousands) at varying locations and I want them to redirect smartly to their correct new locations in the new site.
It seems that I could guard and group related items with a basic regex test on
# These rules aren't considered if the request wasn't for a subpath of categories/software.
# All old store pages now invalid, go to main store.
RedirectMatch 301 .* /software-store/
# Regexes for each category of software to group them logically.
# And so that 1,000s of redirects don't get considered on each page load.
# Loads and loads of redirect lines for pages with arbitrary rules to product pages.
Redirect 301 "/categories/software/item/foo" /software-store/games/foo
Redirect 301 "/categories/software/item/bar" /software-store/productivity/bar
Redirect 301 "/categories/software/item/baz" /software-store/misc/baz
# ...
# Loads and loads of redirect lines. It could also be grouped into subdirectories of dlc/ and so on.
# ...
# ...
For a huge catalogue, a few guarding regexes can prevent thousands of useless tests.
I'm using Apache 2.4, where the
If I remove the enclosing
I suspect that the problem is that I can't nest
http://httpd.apache.org/docs/2.4/mod/core.html#if
Can I nest
No comments:
Post a Comment