Problem with add_rewrite_rule

You’re missing the WP $matches[1] syntax for the regex that gets matched. I think you want /? on the end too. Easiest way I found to test was to temporarily put flush_rewrite_rules() in whilst testing, then you don’t have to do anything else. I have a similar regex which sends /foo/catname/ to index.php?taxonomy=category&term=catname, here’s what … Read more

404 error- issues with pages after adding custom rules for posts

Why it happens The error 404 on the th/<page slug> pages occurs because your custom rewrite rules overwrite the default Page rules which would otherwise load the correct Page (having the slug <page slug>). How to fix the issue If your permalink structure is /%postname%, i.e. example.com/<post slug>, then a simple fix to the error … Read more

Access files at new location using old file paths

I believe I’ve found the solution. I add the following RewriteRule ^example_directory/files/(.*) new_directory/$1 to my WordPress .htaccess rules like so: RewriteEngine On RewriteBase / RewriteRule ^example_directory/files/(.*) new_directory/$1 RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] I couldn’t get it working before and I think the key was moving the … Read more

Double domain name in category URL-s

You can “workaround” the issue with a redirect in .htaccess, although it’s not clear why this double-domain-URL would be accessible in the first place. So, we can redirect URLs of the form example.com/example.com/?cat=6 to example.com/?cat=6, which you then say is correctly redirected to example.com/category by WordPress. For example, at the top of your .htaccess file: … Read more

How to rewrite taxonomy and tags URL

I ended up with this: // Register Custom Taxonomy function fixed_tags_taxonomy() { $labels = array( ‘name’ => _x( ‘Fixed Tags’, ‘Taxonomy General Name’, ‘text_domain’ ), ‘singular_name’ => _x( ‘Fixed Tag’, ‘Taxonomy Singular Name’, ‘text_domain’ ), ); $args = array( ‘labels’ => $labels, ‘hierarchical’=>true, ); register_taxonomy( ‘fixed-tags’, array( ‘portfolio’ ), $args ); } add_action( ‘init’, __NAMESPACE__ … Read more