poptartgun
poptartgun

Reputation: 127

Accessing Codeigniter folder inside Wordpress directory

I have installed Codeigniter into a directory called /portal inside my Wordpress directory. If I visit www.mydomain.com/portal I can see my default controller/view, which is a login page, however if I try to login I get a 404 error in the console for www.mydomain.com/auth/login.

Here's my Wordpress .htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^/portal [NC]
    RewriteRule .* - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>
# END WordPress

And my Codeigniter main .htaccess file

<IfModule mod_rewrite.c>
    RewriteEngine on
    # Send request via index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

How do I get this to work?

Codeigniter 3, Wordpress 4.6.3, PHP 7.

Upvotes: 0

Views: 637

Answers (2)

Semboku
Semboku

Reputation: 71

You just need to add a question mark after the index.php like so:

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

So the full thing (in your CodeIgniter .htaccess file is like:

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

Upvotes: 1

tushar
tushar

Reputation: 161

1) wordpress .htaccess

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

2) Codeigniter .htaccess

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

3) And Changed in your config file i.e portal/application/config/config.php - $config['base_url']

$config['base_url'] = '/portal';

It's work for me, you will try this.

Upvotes: 0

Related Questions