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
- WordPress: How to change name of ADD-ON domain’s folder and also change/rename all references to it
- Site Redirecting to wp-signup.php
- Moving a WP Multisite to a subdirectory
- Remove the blog slug from WordPress Multisite root node
- Multisite on Windows with wildcard subdomains
- Are nested subdomains possible with a subdomain multisite?
- Can a multisite’s blogs be accessible from two different sub-domains?
- WP Multisite development with Mamp Pro and wildcard subdomains, not really working for me
- multisite 404 error for subdirectory
- How to use alias domain for multisite installation?
- Multisite htaccess on localhost with WP as an SVN external?
- SSL wildcard issue for wp multisite subdomains
- What is the best way to load the WP environment in a subdomain of my multisite WordPress install?
- WP-Admin not working properly at WordPress multisite with subdirectories
- Wildcard subdomain for the same site
- Benefits or Problems for using Sub-Directory vs Sub-Domain install of WP Network
- Create multiple subdomains for multi-site from a database
- WordPress Multisite. Can domain be used instead of subdomain?
- Multisite: differences between subdomain and subdirectory mode? Can it be switch after installation?
- How to set up WordPress Multisite on multiple domains without plugin?
- How to modify author base slug with groups and slug to use nice_nickname?
- NGinx + WordPress Subdomain Multi with core in Subdirectory
- Multisite Subdomains result in 403 Forbidden
- Set subdomains live in a next step
- WordPress Multisite – Multiple subfolders for blogs
- WordPress multisite subdirectory redirect infinite loop issue
- Multisite: Develop locally using production images with .htaccess
- Transfer Subdomain site to Multisite setup
- multisite htaccess 301 redirects
- Multisite installation combining subdomains and subdirectories
- How does wordpress multisite manage subdomains?
- How to map permalinks with accented letters to sanitized slugs?
- How to prevent hotlinking with htaccess in WordPress and why most common use about it doesn’t work?
- Remove subfolders from URL
- Why can’t a WordPress network (multisite) in it’s own folder use subdomains?
- “Preview Changes” button doesn’t show changes for previously published posts/pages
- Error 101 after upgrading WordPress
- W3 Total Cache Plugin with WP 3 MultiUser [closed]
- Nginx rules for subdomain multisite install (Bedrock)
- Protect Uploads in Multisite
- Subdomain multisite gives 404 on sub sites
- Add New Sub Site from the WordPress back end then in sub site options table option_value must be with https
- Basically the opposite MultiSite URL question that most people ask
- Domain redirect in WordPress multisite
- Suppress subdirectory from WordPress Multisite primary URL
- custom naming of search permalink /search/
- Auto 301 to full post permalink? (using /posts/%post_id%/%postname%)
- 301 Redirects for posts, category, pages from original domain to sub-domain of multisite
- Fix 403 error on WordPress multisite network using subdomains
- Testing Multisites with vagrant or Can I use multisite with only an IP address (without domain name)
- Changing Multisite URL after the subsite has been in use
- 500 error when using virtual host
- Rewrite rules in multisite
- add_rewrite_rule not registering on Multisite
- WordPress Multisite Login Access
- Why wordpress multisite redirect to wp-signup if site exists?
- Add Rewrite Rule to point to a file on the server
- WordPress multisite htaccess
- Multisite without .htaccess
- Using WP rather than .htaccess to redirect pages/posts
- How do I use different domain for subdomains in WP Multisite?
- Non-wordpress subdomains on Multisite Installation
- .htaccess 301 vs. 302 Enforcing HTTPS
- Images uploading to wrong directory after changing to multisite
- Possible to create a multisite network where the main site is non-WP?
- On WordPress Network(multisite), Sub Blogs in Subdirectories or Subdomains? What’s better?
- Removing /blog/ from multisites cause infinite redirection
- How do I maintain static directories on multisite subdomains?
- Multisite Subdomain Using More Resources Than Others?
- Changing admin sub-domain in WordPress multisite
- How to properly force https and www on multisite with Apache HTAccess
- Subdomain login problems
- wordpress htaccess is hijacking my .mp4 files
- Get Permalink of Network Blog Post
- Change multi-site installation from sub-domains to sub-directories
- How can I have multiple URLs pointing to single WordPress installation?
- How to exclude a directory from WordPress permalinks in a Multisite environment?
- Custom rewrite rule sends 404 header on multisite
- Not able to access dashboard of subdomain
- wordpress multisite subsite rewrite rules not working for videos
- Rewrite my default post URL
- Wordrpess Subdomains (Multi-Site) without Wildcard
- WordPress mutisite migration