You’ll have to modify your old theme’s function.php
. Add the following code:
function redirect_posts() {
global $post;
if ($post->post_type=='post') {
return header('location:http://newblog.com/posts/'.$post->post_name);
}
}
add_action('wp', 'redirect_posts');
The if
codintion will check if the page what’s currently viewed is a post and it returns a header redirect to the new blog based on the old blog post’s slug.
Related Posts:
- How to redirect non-logged in users to a specific page?
- When I change slug, will WordPress create redirect from the old URL?
- Why is WordPress redirecting from http to https on a local environment?
- Why am I getting a 301 on a existing post?
- Keeps on redirecting on my development copy
- Password change when the user login first time
- Custom login form redirect to external site
- Implementing global redirection (automatic redirect for all pages who had their slug changed)
- Redirect to custom url when registration fails?
- Exclude a path from WordPress using .htaccess redirects (Apache)
- How to redirect url requests to https? [closed]
- Best way to handle redirects
- Redirect to custom URL after registering from a page with registration form
- Stop unwanted WP redirection to new url
- wp-login.php — redirect logged in users to custom URL
- WordPress Customizer: custom redirection after closing
- Redirect feed to 404 page
- Hiding WordPress behind IIS redirects
- htaccess 301 redirect http to https doesn’t work
- Site redirecting from http to https [closed]
- Use htaccess to redirect WordPress to static website in a subfolder
- Defining a custom 404 for non-WordPress parts of site
- Redirect all post into some category to url without category
- Redirect from sub-directory to root – New WordPress 5.2.3 Set up
- How to redirect URL with subfolder to the same URL but without subfolder?
- Site loads very slowly (4-5 minute load time)
- If User is NOT Logged in and Page ID is not 6 – Redirect to Login
- Where’s the redirect happening? [closed]
- Snippet for own (gr)avatars
- 503 Service Unavailable error was encountered
- SSL and www to non-www redirection works only on homepage – WordPress
- How to redirect if a background request is still being executed
- Regex with HttAccess
- Regex redirect rule for missing part of the path
- Page template that redirects user based on role
- How can i resolve 301 redirection Issue on my website?
- WordPress keeps redirecting subpages without http to https homepage after switch
- Redirect non-existent subpages to second part of url
- https – too many redirects
- ReDirect subfolder link to another sub-folder and force SSL
- Two WordPress installations: One in root and one in sub directory – no images in subdir installation [closed]
- Redirect user to original url after login?
- A WordPress site with more than one domain name / Parked domains
- Redirect user if they are not logged in
- BuddyPress – Redirects on Login and Logout
- Logout without confirmation and SAME window on mobile
- How to redirect a wrong search on my wordpress website to the error 404 page?
- store URL global before we redirect
- Redirect to page for KPI/marketing purpouses
- Will deleting WP’s code in .htaccess cause problems?
- Migrating to Tumblr [closed]
- Parked domain redirect
- WordPress CSS/Theme gone after SSL got activated
- How can I redirect a request to the site root using htaccess, if there’s not a specific cookie set?
- How to fix automatic redirects?
- Redirecting DNS without breaking everything
- get_bloginfo prints IP instead of url
- How to redirect non existent pages/posts in wordpress using htaccess
- redirect doesn’t work while using example code
- How to redirect all page requests to a single “goodbye” homepage? [duplicate]
- Endless Redirects Suddenly Disable Site
- Redirecting home to /wp-login.php?action=register
- How to redirect a child page to its parent page?
- 301 redirect after removing language directories
- wp_login_form() redirect same page
- Erase the HTML website and replace it with a WordPress website -301 Redirection
- How to replace the links http to https
- Redirect user after login to prior page through a wp_login hook
- Redirect *.php to path using web.config file
- How can force redirected to login for two or more pages to view or access
- WordPress not linking correctly with .htaccess redirect to subdirectory
- Auto redirect to different web page
- WordPress installed on a virtual machine and behind a reverse proxy is redirecting to the VM’s IP address
- Redirect only PDFs in different folders?
- Login redirects to home page and doesn’t log in
- wp_redirect() not redirecting user to supplied URL
- How to redirect?
- using wp_rewrite but keep the original url in the address bar
- Some links keeps redirecting to another domain
- Cannot get 301 redirection in htaccess to work (either Redirect or Rewrite)
- Redirect every link that starts with
- login redirect problem – db charset issue?
- Custom login-form redirect
- Link to another website with the same url path
- Redirect problem: How to redirect to the original URL after login
- .htaccess not working after page slug change
- can’t handle a redirect
- Custom redirects with using SQL
- How to move a https website back to dev and access the admin?
- Getting error when trying to redirect WP site to mobile site
- Custom Form Redirects to Post after Submit
- wp_login_form: Redirect to dynamic url according to username
- Plugin redirects URL structure using 301 redirect. Time to disable the plugin?
- URL is redirecting (301) when query string is passed through URL
- Plugin html-on-pages: URL not redirecting
- Redirect URL while building site
- Redirect a WP to another with all URL
- How to disable login and registration pages?
- How to redirect users without permission to view content to a custom page?
- redirect the root of a domain, while leaving the www version unredirected