I thought this would be pretty simple, however I am having issues permanently redirecting an old template group to a new one.
I have www.domain.co.uk/weddings
which needs to be directed to www.domain.co.uk/more-weddings
.
Both template groups exist, not sure if I need to delete the old one too? Or any other settings in the template preferences?
Here's what I have been trying to use:
RedirectMatch 301 ^/weddings\$ http://www.domain.co.uk/more-weddings
I have a load more redirects which are working too, does this new one need to be placed above them?
You could enable PHP in the older template (weddings/index) and place this in it:
When writing
mod_rewrite
rules, the rules get applied in the order that they appear.In your case, you'd want your
RedirectMatch
to appear before any other rewrite rules — this is especially true if you're removing index.php from your ExpressionEngine URLs.In your example, if you only want to redirect a certain directory (i.e. an ExpressionEngine template group), the following rule will do so, while allowing the rest of the site to function normally:
Make sure this rule appears before your removal of index.php (example below):
If you want Google and other crawlers to see your content as temporarily moved (Response code 302, the default) or permanently moved (301), be sure to configure the RewriteRule Flags appropriately.