You’re close. Add the following to your .htaccess
file in between the <IfModule mod_rewrite.c>
tags that were created by WordPress:
RewriteCond %{HTTP_HOST}
RewriteRule ^(.+)-[0-9]+/$ /$1 [R=301]
Your .htaccess
should looks like the following if it hasn’t been modified by another plugin:
# 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]
# Custom Rewrite
RewriteCond %{HTTP_HOST}
RewriteRule ^(.+)-[0-9]+/$ /$1 [R=301]
</IfModule>
# END WordPress
As a result it will do the following:
http://example.com/category/post-title[-NUMBER]
Redirects to:
http://example.com/category/post-title
Related Posts:
- 301 Redirects for Changed Permalink Structure & Category Base
- How do I turn off 301 redirecting posts (not canonical)?
- Passing variables through permalink structure
- htaccess or redirect to cloak portion of a link?
- Auto 301 to full post permalink? (using /posts/%post_id%/%postname%)
- Using WP rather than .htaccess to redirect pages/posts
- WordPress redirection problem after moving to a new server?
- Specific URL Rewriting with parameters in wordpress
- If I change permalink structures, can I use htaccess to permanantly redirect links?
- Redirect parent taxonomy to it’s child
- Need Help Correct Regular Expression Redirect Code
- Custom Permalink
- Redirect a Blogger Page URL to wordpress
- Redirecting all posts after changing URL structure with htaccess
- Redirect all posts permalinks from “.html” to “/”
- WordPress 4.4 old permalink redirect
- Htaccess https 301 problem
- How to use different domains for different blogs hosted in the same host in subdomains with .htaccess
- What causes /pages/ to appear in URI, and how to remove it?
- Some Pemalink problems, probably caused by wrong .htaccess configuration?
- Test site pages go to main site
- Comment author url link is wrong? How to change from authors/ to author/
- change WordPress permalinks and redirect new urls 301
- Custom permalink structure with %postname% in front of domain name
- Configuring Home Page Address
- Can’t access WordPress site in subfolder possibly because of .htaccess redirect from root installation?
- Removed and Reinstalled WordPress, Redirect Broken now
- redirect old pages by .htaccess
- Why are all pages redirecting to homepage when using custom permalinks?
- .htaccess regex for redirect subdomain to root domain & redirect old permalinks
- 404 posts error after 301 redirection of changed category / tag base
- 301 Redirect posts to newly added categories
- How does WordPress handle permalinks?
- Removing the redirect after changing a page’s slug
- How can I force WordPress to redirect to canonical permalinks?
- Permalink Issues by Installing WordPress in Subdirectory / Subfolder
- Remove subfolders from URL
- Changing pemalink structure to /%post_id%/%postname%/
- Using only %postname%
- removed index.php now all pages 404
- wordpress permalinks tweeks
- Getting a 500 internal server error ONLY on wp-admin/options-permalink.php
- Redirect old permalinks with Month and name to Post name on new site
- Top level Pages redirecting to homepage!
- After moving from subdirectory to home, home page does not display
- Rewrite my default post URL
- Permalinks: Page Not Found
- Post incorrectly displaying as page
- wp_logout_url redirects to incorrect page because of pagination
- Changed permalink structure. Need help with redirecting old posts
- AWS WordPress Install – pages/posts 404 on restart until updating permalinks
- Plain permalinks not working!
- 301 Redirects Result in 404 for WordPress Search Query Strings
- After updating to 4.8 permalinks will not work (all 404)
- Only default permalink is working mod_rewrite enabled
- Changing the post date without causing 404 error
- How do I add /blog/ as a prefix to permalink structure for posts, categories & tags?
- How to change old permalink?
- Redirect Uploads Folder to Query Vars in WordPress
- WordPress url ingore permalinks setting [closed]
- flush_rewrite_rules breaks permalinks
- how to redirect old blog post urls when permalinks are changed
- Accessing Subdirectories in WordPress Install
- How to rewrite a URL to another rewritten URL without changing the address?
- Custom permalinks in WordPress
- How can I make internal anchor links work with WordPress’s permalinks?
- url rewrite .htaccess extension to permalink
- Changing WordPress routing to load the same page for different URLs
- Media/attachment urls don’t redirect with fake URL structure
- Strange behavior: random HTTP error 500 fixed by visiting Permalinks settings page (htaccess issue with language code)
- how to prefer static page if it exists over wordpress page
- I’ve removed my /author/ slug but it clashes with new and existing pages. Any fixes?
- Why will Pretty URLs not Work?
- How Can I Use a Custom AccessFileName?
- xammp server permalink by postname not working
- Conditional Permalink based on category?
- Passing variable as permalink URL
- Blogger To WordPress Permalink Redirection
- new page redirect to old page which had the same permalink
- All pages load the home page if pretty permalinks are used
- Find all URLs for a post
- remove SLASH on single_post but KEEP on categories and parent pages
- where can i see wordpress automatic redirect History
- Extending page urls without getting a 404
- Got 404 error when changed siteurl via DB in WordPress
- Cannot publish posts or pages when I change permalink structure
- How to experiment with permalink structure on a select number of posts
- Very strange behaviour related to htaccess and custom posts and custom posts substrings (BUG?)
- No Ones Been Able to Override my WordPress Rewrite Rule Issue!
- My permalinks for all pages and posts now include old page titles as parents/categories
- Changed Permalinks settings, how do I redirect posts on Nginx?
- WordPress Category url redirects to subdomain
- Remove/hide a specify category-name from the url
- Pretty permalinks (again)
- All pages lead to home
- How do you put your own rules into .htaccess?
- Redirecting From An Old Permalink Structure
- Use .htaccess to redirect homepage to its permalink
- How to use ‘blogs.dir’ as media upload instead of ‘uploads’ directory in WordPress multisite setup
- WordPress not remembering old slugs for pages