I have a theme that has some custom rewrite rules built in to it. The problem is that they are not working with WP multisite. On the install I use to build themes (which is outside of the network), it works fine. When I bring the theme into the network, it doesn't work.



add_filter('query_vars', 'add_mls');

function add_mls($public_query_vars) {
    $public_query_vars[] = 'mls';
    return $public_query_vars;


<?xml version="1.0" encoding="UTF-8"?>
            <rule name="WordPress Rule 1" stopProcessing="true">
                <match url="^index\.php$" ignoreCase="false" />
                <action type="None" />
            <rule name="WordPress Rule 2" stopProcessing="true">
                <match url="^wp-admin$" ignoreCase="false" />
                <action type="Redirect" url="wp-admin/" redirectType="Permanent" />
            <rule name="WordPress Rule 3" stopProcessing="true">
                <match url="^" ignoreCase="false" />
                <conditions logicalGrouping="MatchAny">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
                <action type="None" />
            <rule name="WordPress Rule 4" stopProcessing="true">
                <match url="^(wp-(content|admin|includes).*)" ignoreCase="false" />
                <action type="Rewrite" url="{R:1}" />
            <rule name="WordPress Rule 5" stopProcessing="true">
                <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
                <action type="Rewrite" url="{R:2}" />
            <rule name="WordPress Rule 6" stopProcessing="true">
                <match url="." ignoreCase="false" />
                <action type="Rewrite" url="index.php" />

Now, the part that I see that is similar, but not identical is "Wordpress Rule 3", where in my test site, it looks like this:

<rule name="wordpress" patternSyntax="Wildcard">
    <match url="*"/>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
    <action type="Rewrite" url="index.php"/>

So I went ahead and added the rule from my dev site to the network--but I still don't get anything. Any pointers?


First, I didn't flush the rewrite rules so, or course, the rule wasn't being included.

Second, I ended up going with a MUCH simpler solution to passing the variable to any page with the template applied, which was add_rewrite_endpoint.

add_action('init', 'my_add_endpoints');

function my_add_endpoints()
    add_rewrite_endpoint('myendpoint', EP_PAGES);


!IMPORTANT - add_rewrite_endpoint registers a query var for you and sets that var's value to whatever directly follows it.

So this url:




It took me two days to eventually figure out what should have already been written in the codex. I hope this helps whomever comes across it.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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