I have a WordPress website hosted on Bluehost which contains the following URL pattern:
http://www.example.com/2017/01/30/sample-post/
I want to permanent redirect it to use this:
http://www.example.com/sample-post/
So I opened .htaccess
kept in the example.com
folder and changed it to this
RewriteEngine On
RedirectMatch 301 ^/([^/]+)/$ http://www.example.com/$1
# 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
Then I went to my Permalink Settings in the Wordpress admin and changed my "Common Settings" from "Day and name" to "Custom Structure"
/%postname%/
Now when I access http://www.example.com/2017/01/30/sample-post/
it gives me
404 | Page Not Found! Sorry, but the page you were looking for is not here.
And when I access the URL directly http://www.example.com/sample-post/
it gives me
too many redirects error.
Where am I goofing up?