Ok, resolved it in 404.php
<?php
$klo_link = $_SERVER['REQUEST_URI'];
if (preg_match("/^\/[a-zA-Z0-9\-\_]+\/$/", $klo_link)) {
//echo "A match was found. \n";
//echo $klo_link;
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".get_bloginfo('url')."/a".$klo_link);
exit();
}else {
get_header();
}
Put that at the beginning of the 404.ph
Related Posts:
- Redirect old permalinks with Month and name to Post name on new site
- Custom Permalink
- Changing the post date without causing 404 error
- Extending page urls without getting a 404
- After server migration only the homepage works
- Changing permalinks gives me 404 errors on nginx
- Removing the redirect after changing a page’s slug
- WordPress thinks my custom route is a 404
- URL rewrite based on a custom field value
- How do I turn off 301 redirecting posts (not canonical)?
- Subdomains to pages
- Redirect old permalinks to new permalinks
- How can I include a query string with get_permalink
- Homepage loads but all permalinks are 404 when using nginx & PHP-FPM
- removed index.php now all pages 404
- WordPress on VirtualBox – no pretty permalinks
- WordPress 3.4 Permalinks Redirection Problem
- Random Alphanumeric Key URLs
- Rewrite-Rules not working on a vhost, everything goes to index.php
- Using WP rather than .htaccess to redirect pages/posts
- Does WordPress send a 301 header message when you change permalink structures?
- Permalinks Structure and 404 Question
- Attachment page 404 not found when image is attached to post
- WordPress redirection problem after moving to a new server?
- Changes to permalink structure results in 404 error for all pages other than home
- permalink changed, now getting 404 for every pages
- Clean install – Changing permalinks in twentyeleven give 404
- Post incorrectly displaying as page
- wp_logout_url redirects to incorrect page because of pagination
- Need Help Correct Regular Expression Redirect Code
- Permalinks by page/post name returning 404
- Infinite redirects after changing the permalink of a page
- Editing Pages Give 404 Error After WordPress Upgrade in Admin Panel
- page nested 3 levels deep shows 404
- How to make /search/ without parameters not return a 404?
- Why does the ‘Month and Name’ Permalink Format not Work on my new WordPress Site (running on IIS7)?
- List / Get post redirects
- WordPress post-name permalink redirects to site.com
- Redirect /%year%/%monthnum%/%day%/%postname% [closed]
- Redirecting all posts after changing URL structure with htaccess
- Redirect all posts permalinks from “.html” to “/”
- Unable to get /%postname%/ permalinks working, 404 on all links
- Permalinks stopped working – NO update, mod_rewrite enabled, .htaccess not touched
- how to redirect old blog post urls when permalinks are changed
- WordPress can generate numeric permalinks, which then 404
- 301 Redirect for Non-Date Based URL’s
- Post preview gives 404 when permalinks are purely date based
- How do I make 301 redirection from `/%post_id%/` to `/%postname%/`?
- WordPress suddenly changed all links to example.com/example.com/
- Visiting posts results in 404 errors after host migration
- Comment author url link is wrong? How to change from authors/ to author/
- How do I change the permalink structure without getting 404s?
- Strange behavior with a redirect loop – involves WPML multi-language plugin
- 404 on internal pages, in all sites in my local server
- Redirecting “wrong” but working links to their canonical URL in order to prevent search engine penalties (e.g. /123/ at the end of URLs)
- Getting an ID from a URL, why can WP do this itself, but none of of the functions provided get it right?
- Page redirect to 404 when set Permalink = “Post Name”
- Custom permalink structure with %postname% in front of domain name
- Configuring Home Page Address
- Redirect after permalink changes
- Fix 404 error after changing permalink structure
- WordPress Permalinks 404 bug with “next” button
- Blogger To WordPress Permalink Redirection
- how to set up wp in folder within static website?
- permalink and add_rewrite_rule – error 404
- WP-e-commerce (getshopped) – Annoying permalink issue [closed]
- Problem with special character WordPress
- Need help with major category and permalink re-organization
- Permalinks and page store
- How can i fix my permalinks?
- remove SLASH on single_post but KEEP on categories and parent pages
- WordPress /page/2 gives 404 when custom permalinks is set to %category%%postname%
- How to redirect old permalinks to ones generated by [WP-Hashed-ID] plugin?
- Redirect old /%category%/%postname%/ to just /%postname%/
- Custom structure permalink preventing 404
- why wordpress keeps redirecting to old page after deleting it?
- I have a 404 error on all my pages! What do I do?
- Giving specific category posts its own permalink structure returns 404
- Disable “similar permalink” redirect [duplicate]
- Change permalink structure with post id
- Woocommerce product page 404 not found
- Every sub page shows Error 404, i have check permalink but still same issues
- wp_dropdown_categories links 404
- HTTPS permalinks resulting in 404
- Permalink Rewrite with Archive – Archive gets 404
- How to hide slug numbers with htaccess
- When using number in url it is redircting to same page but when using character it redirects to 404
- Accidentally changed the permalink structure
- Redirect Pretty Permalinks to Ugly Permalinks
- WordPress permalink still not working (error or not understood?)
- Only homepage working correctly, 404 error on everything else
- Removed and Reinstalled WordPress, Redirect Broken now
- Pagination is not working, how to trace it properly?
- My wordpress site must be being affected by outside sources [duplicate]
- 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
- Parent pages not found with pretty permalinks
- WordPress keep redirecting me to random URLs
- Pages resolve at different URLs (different capitalizations)