I have a Wordpress website hosted on Bluehost which contains the following URL pattern:
http://www.somewebsite.com/2017/01/30/sample-post/
I wanted to permanent redirect it to use this:
http://www.somewebsite.com/sample-post/
So I opened .htaccess kept in the somewebsite.com folder and changed it to the following with the help of a suggestion by w3dk.
RewriteEngine On
RewriteRule ^\d{4}/\d\d/\d\d/(.+) /$1 [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
After I wrote this rewrite rule, everything of the url format somewebsite.com/2017/01/30/sample-post works great. However there are a few urls in the website that have the format somewebsite.com/name-of-category/2008/10/20/sample-post
and are throwing a 404 as the result of the above rewrite rule.
I want to permanent redirect www.somewebsite.com/name-of-category/2008/10/20/sample-post
to www.somewebsite.com/name-of-category/sample-post
.
What change do i need to make in my htaccess?