Question

I've been having some issues with my Wordpress install allowing me to access subdirectories, specifically a CodeIgniter install at mydomain.com/codeigniter. I know that technically it should work just fine as-is and recognize folders as they are created. However, this is not happening. I suspect it has something to do with a plugin, but I've tried disabling all of them and the problem still occurs (directs me to the Wordpress 404 page).

I've found a solution in the meantime, however. If I create a subdomain, something changes and everything works like it should, accessing the folder both via the direct path and via the subdomain name.

Any help? I've tried all sorts of fun stuff with my .htaccess files in both directories, but changing them doesn't do anything.

Update: Here's the Wordpress .htaccess in the root folder:

DirectoryIndex index.php index.htm index.html
AddHandler application/x-httpd-php52 .php .php5 .php4 .php

# BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/?codeigniter/
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

And the CodeIgniter .htaccess file in the /codeigniter/ subdirectory.

DirectoryIndex index.php index.htm index.html
AddHandler application/x-httpd-php52 .php .php5 .php4 .php

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /codeigniter
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>
Was it helpful?

Solution

Even though static files and directories do work with a mod_rewrite'd wordpress installation in the servers root you might need to exclude your CodeIgniter subdirectory from that mod_rewrite lineup.

You can do so by placing an additional .htaccess file into the CodeIgniter directory and disable mod_rewrite in there:

<IfModule mod_rewrite.c> 
RewriteEngine off
</IfModule>

Related: apache - Disable mod_rewrite for subdirectory

This normally does the job for me. But it can be less trivial in case that subdirectory needs a mod_rewrite configuration on it's own (as some PHP Frameworks need).

To understand how the apache configuration works, please see Configuration Files (Apache Manual) and AllowOverride directive (Apache Manual).

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top