Moderator
Jan Dembowski
(@jdembowski)
Forum Moderator and Brute Squad
I want to set up multiple .htaccess files, split into folders
OK, that’s doable.
However, as soon as I create a physical folder on the server that corresponds to a URL WordPress is using (e.g. /news, or /services), Apache tries to load that folder rather than letting WordPress handle it.
Huh? *Re-reads* Yes, that’s correct. Why create the folders if you don’t want to use them?
My stock WordPress .htaccess
file looks like this.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
It’s this line RewriteCond %{REQUEST_FILENAME} !-d
that checks if the directory is in use. I’m pretty sure commenting it out will break things (maybe, I’ve not tried).
Is there a way for a phyiscal folder with a .htaccess file inside to exist (e.g. at /news), but for WordPress to still work correctly and load the pages it would normally load if you visited the URL (e.g. /news)?
Can you explain that a little more? If the URL is /news/something-here
and /news/
exists then you want WordPress to let that go unaltered. Or you can put the redirects into the WordPress .htaccess
file above the WordPress part and lose that /news/
directory.
Hi Jan, thanks for your reply, and sorry if I didn’t make myself clear. I think you’ve got the gist of what I want to do, but I’ll try and explain with some concrete examples.
My current site has multiple directories – e.g. /news
, /services
, /people
and /events
. On my new WordPress installation, I’ve got multiple post_types set up, with corresponding slugs of /news/
, /services/
, /people/
and /events/
.
The old site has a very messy structure, so I need to set up thousands of manual 301 redirects – there are no regular expressions that will cover everything. If I put all of these redirects into one .htaccess in the root directory, it would presumably slow down requests. As such, I want to put a separate .htaccess file in each of the folders (/news
, /services
and so on).
For example, I want to redirect /services/services_to_individuals/medical_negligence_solicitors.aspx
to /services/medical-negligence/
using a .htaccess file sitting within /services/
So I want to create a /services/
folder and put a single .htaccess file inside it. However, as soon as I create a /services/
folder on the server, WordPress no longer handles this directory and /services/medical-negligence/
no longer loads.
Is this possible? Thanks again.