: To Fix HTTP 400-499 error codes with 301 redirects in .htaccess file This issue is on WordPress site. I am aware we can change the URL naming convention in WP but I have changed my URL format
This issue is on WordPress site.
I am aware we can change the URL naming convention in WP but I have changed my URL format from date format to simple postname followed by slug as shown below.
Old style:
example.com/2013/02/09/ringdroid
New style:
example.com/ringdroid
Google previously indexed my websites pages (sitemap.xml) with below format:
example.com/2013/04/18/hottest-gadgets-of-2013-to-include-in-your-list www.example.com/2013/02/09/ringdroid
I have resubmitted the sitemap but there are still 404 errors in Google/Bing engine.
Could you please help me to write 301 redirects rule in .htaccess file so when someone clicks the URL for:
example.com/2013/02/09/ringdroid
They should be redirected to:
example.com/ringdroid
How we can write rule in .htaccess file to remove date part 2013/02/09/?
I tried something like this (Googled it), but it didn't work:
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
More posts by @Holmes151
2 Comments
Sorted by latest first Latest Oldest Best
RewriteEngine On
RewriteBase /
RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ / [R=301,NC,L]
RewriteEngine On
RewriteRule ^(d+/){3}(.*)$ / [R=301]
This will strip any sequence of 3 numbers each followed by slashes (so it will work with short year dates like YY/MM/DD dates or single digit days/months like 2013/2/9. If you want to keep the date in the url and have it silently redirect to the correct page without the user knowing, lose the [R=301]
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.