3

I have a multisite WordPress installed on a server using a domain, site.com and I have a subdomain setup in WordPress, so subsites are at sub1.site.com, sub2.site.com etc.

In addition to this, the main site has other services in subfolders that are not related to WordPress, such as site.com/something.

Everything is working fine, except that when a customer on a subsite uses permalinks by post name, and uses the same title as one of the main site's subfolders, it goes to the main site's subfolder; for example sub1.site.com/something goes to the same place as site.com/something.

Is there anything I can do (by editing .htaccess or httpd.conf?

Or should I just move WordPress to it's on subfolder in main site (site.com/wordpress) to prevent these URL collisions?

1 Answer 1

1

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 . '/' . $slug );
}
2
  • Hey that works. Thanks a lot. However, if anyone knows a solution that would actually allow using slugs with the same name as folders on main site, that would be even better.
    – Kari
    Dec 17, 2013 at 8:50
  • @Kari how would you access both if the slugs and folder names are the same?
    – shea
    Jan 2, 2014 at 7:33

Your Answer

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

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