rewriteRules WP6
rewriteRules WP6
rewriteRules WP6
But I want change url to https://cdn.domain.com/favicon.ico, How setting this url with rewrite rules in PHP. You can’t. That’s not how WordPress rewrite rules work. add_rewrite_rule is used for mapping pretty permalinks into the form /index.php?queryvar=value&etcetc. Most servers don’t even load WordPress to handle requests like that for assets and skip PHP/WordPress completely for performance … Read more
Direct domain alias to a specific WordPress page without the page in the URL
Jacob’s comment got me on the right track. Here’s what worked for my issue: add_action(‘init’, ‘cpt_rewrite’); function cpt_rewrite(){ $args = array( ‘public’ => true, ‘_builtin’ => false, ); $post_types = get_post_types( $args ); if ( $post_types ) { foreach ( $post_types as $post_type ) { add_rewrite_rule(‘^’.$post_type.’/([0-9]{4})/([0-9]{2})/?’,’index.php?post_type=”.$post_type.”&year=$matches[1]&monthnum=$matches[2]’,’top’); add_rewrite_rule(‘^’.$post_type.’/([0-9]{4})/?’,’index.php?post_type=”.$post_type.”&year=$matches[1]’,’top’); } } } I used get_post_types() to get … Read more
add_rewrite_rule doesn’t work when trying to add a new parameter at the end of URL
WP-Include rewrite directory
make a new structure tag that does some processing
I was able to solve it doing these rewrites in the following order. So I specified 3 category url in the beginning then 2 category url below that and in the and single category url /combine/brand/category1/category2/page/1-9/ add_rewrite_rule( ‘^combine/([^/]*)/([^/]*)/([^/]*)/page/([0-9]*)$/’,’index.php?category_name=$matches[1]+$matches[2]+$matches[3]&paged=$matches[4]’, ‘top’ ); /combine/brand/category1/page/1-9 add_rewrite_rule( ‘^combine/([^/]*)/([^/]*)/page/([0-9]*)$’,’index.php?category_name=$matches[1]+$matches[2]&paged=$matches[3]’, ‘top’ ); /combine/brand/category1/ add_rewrite_rule( ‘^combine/([^/]*)/?([^/]*)/([^/]*)/?’,’index.php?category_name=$matches[1]+$matches[2]+$matches[3]’, ‘top’ );
Why? This is because the pretty permalink: /tag/online-lectures/?cat=7 gets translated to the ugly permalink: index.php?tag=online-lectures&cat=7 And as you can see the /tag/online-lectures part no longer has the emphasis it once had. Afterall /category/arrester?tag=online-lectures would boil down to exactly the same ugly URL. Since the resulting query is an archive, and the most specific template available … Read more
It looks like your add_rewrite_rule function is not quite correct. The first parameter should be the regular expression pattern that you want to match, and the second parameter should be the query string that you want to rewrite the URL to. Also, you don’t need to include the file extension in the URL. Try updating … Read more