You could just prevent slugs matching existing directories. There are two filters for that.
Example, not tested:
add_filter(
'wp_unique_post_slug_is_bad_hierarchical_slug',
'prevent_directory_slugs',
10,
2
);
add_filter(
'wp_unique_post_slug_is_bad_flat_slug',
'prevent_directory_slugs',
10,
2
);
function prevent_directory_slugs( $bool, $slug )
{
return is_dir( ABSPATH . "https://wordpress.stackexchange.com/" . $slug );
}
Related Posts:
- Sub-subdomain getting redirected to main domain
- Members area with externally-managed htaccess / htpasswd authentication?
- How to disable the default WordPress redirect to non-www URLs?
- Redirect subdomain in Multisite installation?
- Multisite – 404 when accessing sub-sites
- URL redirect/rewrite rule wordpress multisite
- Multisite Subdirectory with same domain subdomain
- Redirect to localhost after installing Multisite on server
- Multisite install w/ Sub domains on a subdomain
- One blog inside another
- wordpress multisite permalink structure: mostly subdomains but not all
- How to show only blog-domain instead of the whole permalink in the loop
- Custom permalink structure with %postname% in front of domain name
- WordPress Multisite and how to apply sef urls only to specific sites
- Multisite, different domains, optional subdirectory, and htaccess
- Network created blogs URL
- Permalinks in Multisite not working
- Site Redirecting to wp-signup.php
- Multisite on Windows with wildcard subdomains
- Are nested subdomains possible with a subdomain multisite?
- multisite 404 error for subdirectory
- How to use alias domain for multisite installation?
- Multisite htaccess on localhost with WP as an SVN external?
- WP-Admin not working properly at WordPress multisite with subdirectories
- Multisite: differences between subdomain and subdirectory mode? Can it be switch after installation?
- How to set up WordPress Multisite on multiple domains without plugin?
- NGinx + WordPress Subdomain Multi with core in Subdirectory
- WordPress Multisite – Multiple subfolders for blogs
- How does wordpress multisite manage subdomains?
- Remove subfolders from URL
- “Preview Changes” button doesn’t show changes for previously published posts/pages
- Basically the opposite MultiSite URL question that most people ask
- Auto 301 to full post permalink? (using /posts/%post_id%/%postname%)
- Rewrite rules in multisite
- Add Rewrite Rule to point to a file on the server
- How do I use different domain for subdomains in WP Multisite?
- How do I maintain static directories on multisite subdomains?
- wordpress multisite subsite rewrite rules not working for videos
- Rewrite my default post URL
- Dissolve Multisite while making site #5 the main site?
- Multisite setup on IIS with subdomains
- Login on Multiple Sub-Domains without Multisite
- How to run a subdirectory multisite install under a subdomain
- Permalinks: Page Not Found
- MultiSite Move conjures duplicate URL
- WordPress multisite in subdirectory, not root, and remove base folder from url
- Enable wildcard in a WordPress Multisite (Sub-Domains)
- Add additional non-rewrite .htaccess directives on multisites via mod_rewrite_rules filter
- Making 2 WordPress sites mutually searchable and more
- Temp URL Redirect Loop
- Error uploading files bigger than 58 MB
- Unable to apply theme to WordPress Network Site install
- multisite subdomain behind reverse proxy
- Some PDF files get Forbidden Access and other open normally on the same directory subsites
- URL without www redirect directly with submission page – Multiwordpress install
- get post id by $content (so by post content)
- WordPress rewrite multisite blog url
- Redirect old uploads after moving to multisite
- WordPress sub-domain multisite 505 error
- WordPress Multisite blogs not working after domain swap
- Multisite, Subdomain, shared NFS directory Linux HELP
- Nginx — WordPress multisite with root folder in own directory
- URL for images folder on Multisite
- Can I safely remove banned names from WordPress?
- How to rewrite a URL to another rewritten URL without changing the address?
- How to use different domains for different blogs hosted in the same host in subdomains with .htaccess
- Multisite – getting a 404 for additional site created using subdomain install
- WordPress in subdirectory, Multisite using subdomains Nginx
- Programmatically creating site in a network
- Migrate single site to Multisites with plugins, cPanel and already working subdomains
- WordPress Multisite with subdomains on different domains
- 404 not working on main site on multisite
- Using Same User Database on Subdomain
- What is with the one month time limit for sub directory installs for multisite network?
- Can I run both a wordpress blog plus another service(ex. a Shopify store) on the same domain?
- How to update wordpress content of wordpress multi-site subdomain
- Rewriting request to another site
- Getting file errors in a WordPress Multisite ADMIN
- WP Multi Site – configure Sub domain pointing to parent sub directory
- Multisite network subdomains doesn’t work
- trying to install a wordpress multisite in a subfolder and have custom subsite urls
- Events Calendar Multisite 404 for events
- new WPMS site not working / Q setting up new site/subdomain
- Applying Child Theme to another site, which has its own URL
- No Ones Been Able to Override my WordPress Rewrite Rule Issue!
- My permalinks for all pages and posts now include old page titles as parents/categories
- WordPress Category url redirects to subdomain
- WordPress Multisite subdomains and sharing the same upload folder
- WordPress MU with subdomain
- Configuring Multisite with subdomains
- WP Multisite .htaccess interferes with cgi-bin
- How do I remove ‘www.’ from all internal links in self-hosted multisite?
- How can I set up a completely separate (not multisite) WordPress installation as a subdirectory of an existing WordPress blog?
- Multisite: should /blog go to a 404 page?
- Not being allowed to use some terms in Add New Site in WordPress
- Multisite website configure Domain issue
- External rewrite rules missing in htaccess – Multisite
- Multisite subdomain site on secondary domain
- wordpress multisite with already existing subdomain
- Multisite: Redirect a deleted site – Best practice?