Question

I am trying to do a simple 301 redirect for the following URLs:

From:

http://example.com/blog/category/*
http://example.com/blog/tag/*

To:

http://example.com/category/*
http://example.com/tag/*

Where the * character represents any given category or tag that could possibly be requested.

So I need to have a wildcard in place so that whenever any category or tag is requested, it redirects to the URL without the blog folder.

Is there any way to achieve this with a 301 redirect in my .htaccess file?

Was it helpful?

Solution

RedirectMatch would be better for its regex capabilities. Use this rule in your DocumentRoot/.htaccess:

RedirectMatch 301 ^/blog/(category|tag)/(.*)$ /$1/$2
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top