• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.htaccess issues with CI3 inside Wordpress directory

#1
I have Wordpress installed in my web root and also have a directory inside that web root with Codeigniter 3 installed. 


Code:
/www
      /wp-admin
      /wp-content
      /wp-includes
      ...
     /codeigniter


When I visit a default controller method like 


Code:
http://mydomain.com/codeigniter 


I can see my login page (codeigniter/auth/index). 

But I i visit anything beyond that, such as 


Code:
/codeigniter/auth/login 


I get a 404 error in the javascript console and the error "No input file specified" in the browser.  

My Wordpress .htaccess:


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


My Codeigniter .htaccess:


Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>


I have tried everything, how do I make this work?

If I add index.php back into my URL it works, but of course i don't want that. 

So http://mydomain.com/codeigniter/index.php/auth/login works but
http://mydomain.com/codeigniter/auth/login does not work. How do I enforce
the no index.php version (that works if CI is in it's own directory) while inside
a WP directory?

I have tried this, no luck.

Wordpress:


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


Codeigniter:


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

#2
Daft question but does mod rewrite work on your hosting. That would be the first thing to look at. Sadly configuring the htaccess for different environments is pretty hit or miss. Just keep trying different configurations.
IgnitedCMS Pro
IgnitedCMS
Practical guide to IgnitedCMS - Book coming soon
Reply

#3
I usually just use a single .htaccess:

Code:
# URLs routed to CodeIgniter
RewriteRule ^foo/.*$ /ci_index.php [L]
RewriteRule ^bar.*$ /ci_index.php [L]

# Everything else goes to WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Reply

#4
(02-26-2017, 12:38 PM)skunkbad Wrote: I usually just use a single .htaccess:

Code:
# URLs routed to CodeIgniter
RewriteRule ^foo/.*$ /ci_index.php [L]
RewriteRule ^bar.*$ /ci_index.php [L]

# Everything else goes to WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
 
Unfortunately this throws a 500 error on my CI pages.
Reply

#5
(02-26-2017, 09:46 AM)ignitedcms Wrote: Daft question but does mod rewrite work on your hosting. That would be the first thing to look at. Sadly configuring the htaccess for different environments is pretty hit or miss. Just keep trying different configurations.

Yes, wordpress and CI both work independently in different directories.
Reply

#6
(02-26-2017, 03:27 PM)baxterheinen Wrote:
(02-26-2017, 12:38 PM)skunkbad Wrote: I usually just use a single .htaccess:

Code:
# URLs routed to CodeIgniter
RewriteRule ^foo/.*$ /ci_index.php [L]
RewriteRule ^bar.*$ /ci_index.php [L]

# Everything else goes to WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

Unfortunately this throws a 500 error on my CI pages.  


This wasn't meant to be complete, it's just showing that I'm routing to two different front controllers. Also, systems vary, and sometimes a perfectly working .htaccess file doesn't work on another machine.

Do be sure that in your apache config that you've got AllowOverride set to All. Just because mod_rewrite is enabled doesn't mean your .htaccess can do what you want it to.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.