You can actually use PHP to make redirects, rather than just .htaccess, which has the benefit of allowing you to use variables.
I don’t really know woocommerce too well but you could create a redirect similar to this.
Note this is pseudo code. These function calls are fictional but the logic
will still apply
function redirect_product() {
$product_status = get_product();
$product_url = get_product_url();
if ($product_status === NULL) {
$URL = $_SERVER['REQUEST_URI'];
if ( $URL == $product_url) {
header( 'HTTP/1.0 301 Moved Permanently' );
header( 'Location: /' ); //redirect to url of your choosing
exit();
} else {
return;
}
}
}
Related Posts:
- woocommerce shop page Redirect Help
- Redirect After Delete User in Backend
- How can I move/redirect single blog posts from one blog to another?
- Custom domain for sub-section of parent website
- How does WordPress redirect to WooCommerce shop page? [closed]
- Does WP always makes 301 redirection?
- htaccess 301 Redirect not working for WordPress site
- How to set 301 redirection after moving WordPress blog?
- Redirect custom post type from one domain to another domain
- Built-In Postname Redirection vs Hard Redirects in relation to SEO and performance
- Redirecting Pages That No Longer Exist — But Could in the Future
- How to remove the [L] Flag for WordPress index .php mod_rewrite
- WooCommerce – Redirect to a product after login
- About to migrate site to new domain
- WordPress directing to Posts page (edit.php) instead of saving post
- Erase the HTML website and replace it with a WordPress website -301 Redirection
- Is it ok to 301 redirect product-category pages to custom pages?
- 301 Redirect in WordPress not working in htaccess
- Unable to access WP test site
- Resolving the too many redirects on wordpress
- What is the best practice workflow for new website overhaul and keeping current SEO ranking? [closed]
- Woocommerce login to specific page or referrer
- How to handle expired assets/content when user has direct URL
- Best SEO way to redirect from all “posts” to home url
- How do make WordPress to let alone my static home page?
- Problem after redirect homepage to /en/
- woocommerce display product category on checkout page [closed]
- how to get my WP site’s IP? [closed]
- How to change Ugly link?
- Woocommerce linking variations
- How can i move my product name & price from below thumbnail to be the rollover content in Avada & Woocommerce?
- WordPress site redirecting to developers URL
- How to use the HTTP API (wp_remote_get) instead of cURL?
- Redirect ignore last URL segment
- Create a 301 Redirect automatically when adding %category% in the permalink
- Creating custom link that redirects to a another link
- Other pages fine but wp-admin showing ERR_TOO_MANY_REDIRECTS Error
- Simple function not working on frontend and can’t figure a way to debug it
- How to disable login and registration pages?
- 301 redirect just for 404 to another domain
- Redirected You too Many Times and Homepage Not Loading
- Create Custom Coupon Type
- Forcing header cache control in 404 pages
- Delete old thumbnail when updating new
- Regex for pdf’s – Old .asp Site folder structure to new WordPress Media Folder(s)
- Save And Display Mp3 Audio files on WooCommerce product page with Dokan
- Change the User/ Author of the Products
- Redirect if a user has not written a post
- Show total sales for each products on search results page Woocommerce
- How to redirect non-logged in users to wordpress login page and bypass some page IDs?
- 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
- Redirect all pages to the custom login page except for the registration page
- Redirect to Homepage if URL contains string
- How to Create Custom Route to a page in WordPress
- How to create a redirect to another domain like safe redirect manager from php
- redirect to 404 page
- How to redirect to a page after submitting form data?
- Post Migration Site Migration Redirects All Known Solutions Attempted
- Add a simple php code snippet to redirect a single wordpress url to another
- Is RewriteMod for WordPress site: site.ro -> site.com/?lang=ro possible?
- Product customizing quiz – quiz adding products to the cart
- Create a custom redirect link that tracks the first visited page and after submitting form goes to first page using formidable forms plugin? [closed]
- Change in credit card payment button for woocommerce
- WordPress not use site url when redirect 301
- Page with redirect
- Is there a way to redirect people from a page on my .com website to a corresponding page on my .co.uk website if they are in the UK
- wp_redirect() doesn’t work
- Redirect old homepage to the new one within the same site
- How to find out what is causing redirect of static content?
- How to setup an automatic redirect for when there has been a critical error on the site?
- When invalid child page entered, WP redirects to next available page instead of giving Page Not Found
- How to force HTTP and stop SSL completey on WordPress website
- Redirection after Category Change for Custom Structure
- How to display product variations on same row
- Redirect certain 404 pages to parent page
- After migration index page still redirects to old url
- Redirect non-logged in users to a specific page
- redirect site links form joomla to WordPress
- Custom product sorting archive page
- Redirecting by role from a button
- How can I redirect the user to the page they were on when they clicked “Lost Password” using “retrieve_password_message” filter
- Copy and Modified WooCommerce function is_coupon_valid [closed]
- Redirecting logged in users to custom URL
- Redirect to File attached to a Post using ACF
- Where to add wp_redirect on frontend pages?
- WordPress post slug redirection
- Redirect all pages to a specific page of a new domain but exclude specific pages
- Custom fields in the billing address section woocommerce
- Make category page the wordpress homepage (not blog)
- Woocomerce custom add to cart button edit functionality [closed]
- Are post permalinks and wp_redirect() redirections saved in browser cache?
- Add a custom field for sorting the products in a specific category WOOCOMMERCE – Second try
- Forward and mask implementation not working,
- Add a custom field for sorting the products in a specific category WOOCOMMERCE
- Running non-WordPress PHP files
- Why Does My Website Redirect to HTTP Before HTTPS When Accessed Without a Trailing Slash?
- How to Setup 2 Domains on a Single WordPress (Regions Filter)?
- How to get selected variation from URL?
- woocommerce, add free sample button on product page