So, you’ve just switched from the default WordPress permalink structure and now your permalinks are returning Not Found (404) errors, or you didn’t do anything at all and they’re return the error.
First, there could have been a momentary glitch, so try re-saving your permalink structure at Settings/Permalinks in your admin panel. If WordPress cannot automatically edit the .htaccess file, it will provide manual instructions after saving.
If that doesn’t work, contact your hosting provider and find out if mod_rewite is installed and active on your server. If it isn’t, refer to this guide for some tips on using permalinks without mod_rewrite, or find yourself a nice Apache-based server with mod_rewrite.
Permalinks are a finicky thing. They’ll either work right away, if you re-save, and if you use a work-around, otherwise they just won’t work at all. If you’re still having trouble, contact the WordPress Support Forums for more assistance.
the problem i got is that it works after resaving, but it does not work using function, what is the way I have been doing it before:
$permalink_structure = get_option(‘permalink_structure’);
$category_base = get_option(‘category_base’);
$tag_base = get_option( ‘tag_base’ );
$wp_rewrite->set_permalink_structure($permalink_structure);
$wp_rewrite->set_category_base($category_base);
$wp_rewrite->set_tag_base($tag_base);
$wp_rewrite->flush_rules();