Welcome Guest, Not a member yet? Register   Sign In
.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.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
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

(This post was last modified: 02-26-2017, 08:06 PM by ciadmin.)

(02-26-2017, 11:38 AM)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, 08: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, 02:27 PM)baxterheinen Wrote:
(02-26-2017, 11:38 AM)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
#7

(02-26-2017, 02:28 PM)baxterheinen Wrote:
(02-26-2017, 08: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.

Are you sure about that? The structure you originally posted has Codeigniter as a subdirectory within WordPress. That means that /codeigniter/auth/login is routing through the .htaccess rule for WordPress most likely. It seems really simple to me. On your WordPress .htaccess, you would add:

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

Any URI starting with codeigniter won't be processed in that first RewriteCond. I left it in parathensis incase additional items have to be added similar in the CodeIgniter .htaccess.

The reason using codeigniter/index.php works is because of that !-f in the second RewriteCond which means the condition is true if the request is not a file. The following is if the request is not a directory.
Reply
#8

(This post was last modified: 04-28-2017, 04:59 AM by arisroyo.)

Here is mine hope it will works with you.

My primary base folder for example is public_html and can access through http://localhost
and I have CI project openspire that can be access through http://localhost/openspire/

And here is my .htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /openspire/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /openspire/index.php [L]
</IfModule>
There are those who tell lies with meaning behind them and those meaning less lies!
Reply
#9

Oh make sure your mod_rewrite is also enabled! Smile
There are those who tell lies with meaning behind them and those meaning less lies!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB