WordPress – Stop WordPress from hi-jacking CodeIgniter URLs using .htaccess

.htaccessapache-2.2codeigniterWordpress

WordPress is installed in the root web directory:

/var/www/html/

CodeIgniter is installed in a sub-directory:

/var/www/html/ciapp/

When I access http://www.example.com/ciapp/ the main CI controller is accessed and executed correctly.

However, if I try to access my main CI controller directly like so:

http://www.example.com/ciapp/main/

I get WordPress's 404 page. Also, if I attempt to access a function of my main controller like this:

http://www.example.com/ciapp/main/myfunction/

I also get the same 404 page.

So, basically, WordPress is ignoring the /ciapp/ directory by default, but it's not ignoring any URL requests that are added to it. Here is my WordPress .htaccess:

# BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

So what kind of RewriteCond do I need to add to the WordPress .htaccess for it to ignore the /ciapp/ directory and any URI request that uses that directory as well?

I tried this:

RewriteCond %{REQUEST_URI} !^/?ciapp

But it didn't seem to have any effect.

Best Answer

if url == any of these, do NOT use index.php to serve them.

RewriteCond $1 !^(index\.php|css|img|forums|ciapp|robots\.txt)

else, use index.php

RewriteRule ^(.*)$ index.php/$1 [L] 

if url == ciapp/* , use ciapp/index.php to server them.

RewriteRule ^(.*/)?ciapp/(.*) /ciapp/index.php/$1 [L]  
Related Topic