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!

1 Answer 1

6

The RewriteBase in the codeigniter directory should say /codeigniter/

RewriteBase /codeigniter

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

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.