Reputation: 21
I have a custom post type in Wordpress the following slug:
domain.com/folder/page-1
I want to redirect all /folder/ links/URLS to another URL.
For example:
All redirect to domain.com/some-page
Upvotes: 1
Views: 1199
Reputation: 38
If you have many URLs to redirects, its better to use plugins, suggest plugin Simple 301 Redirects
Another methods is use wordpress function wp_redirect();
add_action('template_redirect', 'redirect_page_another_page');
if(!function_exists('redirect_page_another_page')){
function redirect_page_another_page(){
$queried_post_type = get_query_var('post_type');
<!-- replace custom_post_type_name with you custom post type name -->
if ( is_single() && 'custom_post_type_name' == $queried_post_type ) {
$redirect_url = site_url().'/folder/some-page/';
wp_redirect( $redirect_url );
exit;
}
}
}
Upvotes: 0
Reputation: 41229
You can use RedirectMatch directive for this :
RedirectMatch ^/folder/.+$ http://example.com/page
Upvotes: 0
Reputation: 736
How about:
RewriteEngine on
RewriteRule ^domain.com/folder/(.*)$ domain.com/some-page [R=301,L]
Upvotes: 1