Mobile app version of vmapp.org
Login or Join
Holmes151

: 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

@Holmes151

Posted in: #Htaccess #ModRewrite #UrlRewriting #Wordpress

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/rin​gdroid

New style:
example.com/rin​gdroid

Google previously indexed my websites pages (sitemap.xml) with below format:
example.com/2013/04/18/hot​test-gadgets-of-2013-to-include-in-​your-list www.example.com/2013/02/09/rin​gdroid


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/rin​gdroid

They should be redirected to:
example.com/rin​gdroid

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

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Holmes151

2 Comments

Sorted by latest first Latest Oldest Best

 

@Shakeerah822

RewriteEngine On
RewriteBase /
RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ / [R=301,NC,L]

10% popularity Vote Up Vote Down


 

@Rivera981

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]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme