I want to create a permalink (chris-admin) for a custom admin backend site located in my child theme directory (wp-content/themes/t25child/UI/). Been playing around with Wordpress' rewrite rules to achieve this and noticed a stranged behaviour:


The rule isn't even accepted by wordpress. I tried around for hours and realized that wordpress only accepts rules which have index.php as redirect target. The rule below is working like a charm.


Can anyone give me more insight on this?

Thank you very much!

1 Answer 1


There are two different rewrite systems at play when you have pretty permalinks enabled.

The first is Apache's mod_rewrite, which basically sends any request that isn't for a physical directory or file to the main WordPress index.php file.

The second system is internal to WordPress, and handles conversion of pretty permalinks into their component query vars, so the database can be queried for the requested content.

Now, your question: Does add_rewrite_rule(..) only accept “index.php” as redirect target?

No, you can add both kinds of rules via add_rewrite_rule. WordPress will look for index.php and add that rule to the internal rules, or will otherwise add it to the array of external rules.

So, if that's the case, why isn't your rule working? First, verify that the rule hasn't made it into the .htaccess file. For new rules to be written to .htaccess, the rules need to be flushed, but not an ordinary flush. flush_rewrite_rules accepts a single boolean argument, which is false by default. Setting that to true will cause WordPress to regenerate the .htaccess file, and your rule should appear.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.