<?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
- Functions.php code that only runs on localhost?
- hook a functions to change wp-config from functions.php
- Add a Post Thumbnail to an RSS Feed with custom size
- Ajaxing function in widget class
- Run function when WordPress new multisite is created or ACF field is updated
- Frontend tag edit/submit form
- Redirecting amp url to non amp url
- Sections and tabs DRY – WordPress settings API
- Has is_archived() for sites in a multisite changed with WP 4.7?
- Custom function causes a 503 error after a couple of hours
- Undefined index: action with code-snippets to change register page
- Why There Is No “get content by ID” Function
- How to fix URL with pageid example /?p= too many redirection error
- wp_usermeta – Read from database, but save function broken
- Output comment_author in array
- Problem with shortcode inside a shortcode
- How to add class dynamically from templates
- How to change form action of wp-login page with a function
- .htaccess redirect for old subfolder installation to new subfolder installation and https
- Translation Function missing text-domain [closed]
- Custom taxonomy not refreshing page on add
- disable WP_error: authentication_failed
- How to automatically load Google Fonts on pages only as they’re used?