5

I'm having some issues with a Codeigniter app in a subfolder on my server along with a Wordpress install in the document root. If I hide the index.php of the Codeigniter URL with .htaccess

/codeigniter/.htaccess

DirectoryIndex index.php

<IfModule mod_rewrite.c>

  RewriteEngine on
  RewriteBase /
  RewriteCond $1 !^(index\.php|user_guide|robots\.txt)
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d 
  RewriteRule ^(.*)$ index.php/$1 [L,QSA]

</IfModule>

<IfModule !mod_rewrite.c>
  ErrorDocument 404 index.php
</IfModule> 

And get Wordpress to ignore /codeigniter with RewriteCond %{REQUEST_URI} !^/(codeigniter).*$

/.htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/(codeigniter).*$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Then navigate to www.mysite.com/codeigniter/my_controller/my_function, I get a 404 error No input file specified. I found here, that adding a ? after RewriteRule ^(.*)$ index.php solves the Codeiginiter 404 error.

/codeigniter/.htaccess

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

However I'm now getting a Wordpress 404 error, so it seems if I replace index.php with index.php? in /codeigniter/.htaccess, the Wordpress rewrite rule in /.htaccess, RewriteCond %{REQUEST_URI} !^/(codeigniter).*$ gets ignored. Is there a better way to handle this?

Thanks in advance!

Community
  • 1
  • 1
dcd0181
  • 1,493
  • 4
  • 29
  • 52

1 Answers1

6

The RewriteBase in the codeigniter directory should say /codeigniter/

RewriteBase /codeigniter

Otherwise the rewrite to index.php ends up going to wordpress' router.

Jon Lin
  • 142,182
  • 29
  • 220
  • 220
  • Thanks, I just figured that out, FYI `RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php/$0 [PT,L]` also works. – dcd0181 Dec 18 '12 at 23:55