I’m currently transitioning a website from their existing CMS to WordPress.

I have a custom post type of ‘Episodes’, with a URL of myurl.com/episodes/

There is also an existing directory at myurl.com/episodes/ which needs to remain in place for historical reasons – it contains a large number of images and static HTML files which will still need to resolve.

At the moment, because the /episodes/ directory exists, WordPress won’t go anywhere near it, so the pages under my custom post type don’t load.

This happens because WordPress’s default .htaccess has two rules, which state that any existing file or existing directory should be not be handled by WordPress:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

But these rules stops /episodes/ from being handled by WordPress at all. I want WordPress to handle /episodes/ by default, and only not do so if the file in question exists.

But having the first line on its own – i.e. pass everything to WordPress unless the file in question exists – doesn’t seem to do the trick.

Is there a way I can re-write these rewrite rules so that WordPress will still handle the request if the directory exists, but not if the file exists?

2 Answers
2

Not using WordPress. With that directory in place, your web server doesn’t even touch WordPress when it handles the request.

I would:

  • Move as much of your stuff as possible away from using that folder
  • Rename the rewrite rule so that it’s not just /episodes/ so that it doesn’t clash

You could try moving the folder and adding redirects, but at that level you’re at the Apache/Nginx level, not the WordPress level

Leave a Reply

Your email address will not be published. Required fields are marked *