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?
- Safely redirect old WordPress blog links to new WP blog
- How to force a 404 on WordPress
- Disable ONLY URL auto complete, not the whole canonical URL system
- 301 redirect instead of 404 when URL is a prefix of a post or page name?
- Correct way to hide pseudo pages from being shown?
- Htaccess redirect from ‘/%postname%.html’ to ‘/%postname%’
- Redirect to post after submission with Gravity Forms? [closed]
- Stop WordPress Redirection From /keyword to /some-post-containing-keyword/
- Specific URL has 403 Forbidden status code
- Redirect members to custom page upon logging in through WP admin
- I want to redirect the url to the previous page
- woocommerce_before_calculate_totals in woocommerce 3.0
- Headers already sent – WordPress core
- Import WordPress Post Slug with Forward Slash
- Why specific file directory fails to redirect but its parent folder succeeds?
- Cant Access Website – Changed HTTP to HTTPs
- How to remove “YEAR/MONTH/” from uploads URL & redirect old URL to the new form?
- How to redirect user to a page after form submission
- Add attribute / custom attribute to product in woocommerce
- Delete link on single-custom.php with redirection
- 301 Redirect To Post ID
- redirecting and showing notice from previous action
- Make posts 410 dynamically
- Viewing checkout page removes fees from mini cart
- Always redirect current user to certain page
- How to redirect to clean links with this code
- How can I make my WordPress site redirect to subdomain once successfully login they will redirect back to root domain
- help to change some colors (woocomerce and store locator) [closed]
- 301 Redirect all page and post urls from .html to /
- wordpress_redirect returns different headers for HEAD and GET requests
- How to Get WordPress custom post data in WooCommerce product meta panel? [closed]
- Login/Register redirect user with message
- wp_login_form redirect problem
- Redirect from ip to domain
- How can I redirect users on the new 404 page without plugin?
- How do I write a subdomain redirect?
- How does WordPress format the url on a 301 when a trailing slash is missing?
- Redirection on domain name
- Redirect only Blog posts to new
- Add attribute taxonomy through code don’t appear in admin product page
- Showing different pages depending on a cookie value
- Unwanted slug in my website
- HTTPS to HTTP rewrite rules not working as expected
- Changing permalinks and redirecting urls
- htaccess 301 Redirect not working from aspx to new WP permalink
- Mass .htaccess URL Forwarding
- Redirecting simple big problem
- Wp Remote get with manual redirect
- Add base folder to CPT and 301
- wp_logout_url redirect not working
- How do i make WordPress return 404 instead of redirecting on misspelled page?
- how to redirect non logged users to login page and redirect to another page with saved data?
- Add a new view on the Woocommerce account page
- How to get the full product name by ignoring custom modification on it
- How to automatically redirect category pages (301) when changing the location of a category in the hierarchy
- My wordpress local urls is still displayed even moved to live
- Upload advanced custom field text link array with csv
- How to redirect user to Referrer Page using wp_signon in Custom Login Page in WordPress
- Including a Customized Initialize File with a wordpress header
- redirect after account activation for forum using bbpress and buddypress
- How to Remove wpautop in woocommerce includes folder class-wc-order-item.php
- redirect_to ignoring the SSL
- WooCommerce Variation Swatches and Photos – get attribute thumbnail
- Redirect wordpress website URL into other link
- Serve wordpress regardless of the cname
- Pass original URL through after login redirect
- Force SSL on a single page which is used as iFrame
- Redirect Every Instance of The Author Template Pages to Custom Author Pages
- Show page without reference to post (like front-page)
- How to redirect all pages of a blog to a new blog
- WordPress as a Facebook app
- URL Custom Rewrite
- Create Custom Coupon Type
- Post Migration Site Migration Redirects All Known Solutions Attempted
- Custom product sorting archive page