<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://{$_SERVER['SERVER_NAME']}/subcategory{$_SERVER['REQUEST_URI']}");
exit();
?>
The above code was added directly to themes 404.php and everything worked as expected
Related Posts:
- 404 redirect to previous category
- How do I skip wordpress’s 404 handling and redirect all 404 errors for static files to 404.html?
- Use author author display name in permalink structure for pages and posts
- PHP – redirect https to http and www to non-www
- Masking logout URL
- Logout/login redirect CSS issue
- Paged Single Post doesn’t redirect to the main url after Removing Pagination
- redirect wp-login.php to another page
- How to add .htaccess code through a function?
- How do I skip wordpress’s 404 handling?
- How do I redirect upon login a specific user based on role?
- Why specific file directory fails to redirect but its parent folder succeeds?
- WordPress Content Security Policy and Subresource Integrity
- WordPress blocking/preventing viewing of .cgi file in subdirectory [closed]
- Post Pagination Showing Same Posts Every Page
- Completely disable RSS feeds on WP 5.5.2 and show a 404 page instead of die();
- Deny access to a path (give 403 or 404 response)
- Ninja form Redirect depending on text field content [closed]
- Issue with htaccess redirection in WP Multisite
- Redirect specific page in WordPress for first time visit
- Custom Permalink
- Built-In Postname Redirection vs Hard Redirects in relation to SEO and performance
- Login Redirect if Logged in from Specific Page
- Redirect to another page if the user is logged in when pressing again the login button on menu bar
- Using wp_redirect and .htaccess to re-route searches (and pass along the remaining GET vars)
- Incorrect redirect after commenting
- Remove category from url
- WP function won’t work on 404 template page
- I used single quote to design HTML of my WordPress blog. Now site redirects to index.php everytime than page.php or single.php
- How i can put $_GET codes in function.php?
- Why does get_template_directory_uri() not include “www”, only for enqueued stylesheets?
- Testing for a shortcode using a function. 404 page throwing PHP Notice
- Page get parameter doesn’t work with is_single() function
- How can I redirect users on the new 404 page without plugin?
- How to redirect an old page url to the homepage
- How to rewrite wordpress search to work on specific category
- Redirect website domain (including all pages) to external URL after Popup message (few seconds)
- Contact Form 7 If Condition
- Solved: redirect to another page using functions.php
- Redirect to other page if login
- Logout Redirect and also WP-login.php Redirect
- How to add array [closed]
- WordPress website keeps loading the maintenance page
- Redirects based on a JSON file
- 404 redirect based on url
- How to redirect non existent pages/posts in wordpress using htaccess
- Internet Explorer opens links to .msi files as text in a new tab
- template_redirect action only firing if logged in
- How to redirect Subscribers on login to specific page, when logging in from a Page
- Redirect to one of two pages after data submitted, depending on the current url
- Javascript file loads only on homepage, not on other pages (404 not found error)
- multisite 404 subfolder same name slug as site
- Wildcard 301 Redirect Using Theme Function
- Competing Login Redirects – Need to be Combined?
- Postback redirect through add_action is not triggered
- Function for Sticky Post on Categories causes issues with 404 behavior
- Unable to declare AOS library in functions
- Restrict access if logged out except for homepage
- Redirect specific author posts to another url
- How do I skip wordpress’s 404 handling?
- Custom download page
- redirect 301 with special character like WIX site “#!”
- How to create a function to redirect a specified page to another page
- Language switcher for subdomains
- Changing post per page causing 404 for pagination. Need a redirect htaccess rule
- Allow the access over wp-login.php
- Subpages return 404 server error
- htaccess redirect for all categories converted to tags now showing 404
- How to request login for user but not for bots
- Changing functions.php and .htaccess files
- Making an under maintenance page (without using plugins)
- WordPress subfolders htaccess bypassing the root htaccess RewriteRule
- How to Redirect Url to homepage?
- WordPress is adding pagination for all pages not only for blog page, How to remove pagination for all pages except blog/posts page?
- Template Redirect Function Only Working When Logged In
- Post pages are redirecting to the 404 page in wordpress
- Disable Attachment Page Except for Category
- Redirecting after login except for a specific page
- How to redirect using a custom wordpress api endpoint after form submission?
- wp_nav_menu work in functions.php but not in the theme
- How to register a menu based on a ACF condition
- get_template_directory() – references parent theme directory
- Custom permalink structure with %postname% in front of domain name
- widgets not working
- Configuring Home Page Address
- WooCommerce -> wc_enqueue_js not working [closed]
- Use existing image sizes for WooCommerce
- 404 not working on main site on multisite
- Only echo Page Content (not page title & page content together)
- Function that prevents users from uploading photos more photos
- How do I display a date correctly that is stored in the database as a backwards 8 digit number from Advanced Custom Fields? [closed]
- How to convert raw url to hyperlink?
- Insert function insde body tag
- Shortcode to get featured image of specific id post
- Split single-review.php to two parts
- Redirect Image Url to a page via htaccess
- Modify shortcode to work with custom post types
- How to hightlight all ancestor menu items of a child page NOT displayed in menu
- Sort and display pages with specific custom field (not tag)
- update_post_meta is Updating with two page id