Using Codeigniter within Wordpress

Asked

Viewed 449 times

1

I am working on a blog where within a specific page it has an iframe that points inside the server itself, calling a folder that contains the running Codeigniter.

Until a few days everything worked, this in the old server. I had to switch server and the current server does not work. The only page it opens is the page configured in codeigniter to be the initial, when I need to access a controller I get an error 404.

Wordpress tries to access a folder, and actually this folder does not exist, for example I inform the following url:
server.com.br/codeigniter/controller/action/

Instead of entering the controller and looking for the action it looks for folders and obviously these folders don’t exist, I created folders with these paths and it got the index I put inside the "action" folder, but that’s not what I need. I need it to behave like a framework.

I need a way that when I point to server.com.br/codeigniter/ it understands that it is no longer to behave as if it were the blog, and start behaving like a framework.

I don’t understand anything. htaccess is one of my worst points as a programmer, I tried most of the day to fix a solution with htaccess, but as you can see I had no success, I’m not sure if the correct way to solve this problem would be with htaccess, but it was the only possible exit I could find.

Follow htaccess from wordpress:

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

And also htaccess from codeigniter

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

If I enter the codeigniter directly by a subdomain the program runs perfectly, however, I cannot access iframe with a subdomain, as I need to retrieve data/variables from within iframe with jQuery/Ajax, if I use a subdomain this is not possible, I need a way to make the blog understand that when it’s server.com.br/codeigniter it starts using codeigniter htaccess, or it enters the controllers instead of looking for folders, (I think this is the solution.)

1 answer

2

I managed to solve my problem, I needed to discover some new functions of .htaccess that I did not know, the problem is that I am with many doubts in mind and I can not kill the doubts on Google, do what...

Follow my resolution, maybe help someone.

The .htaccess of the framework was thus:

Options +SymLinksIfOwnerMatch
RewriteEngine on

RewriteBase /online/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?/$1 [L]
  1. I needed to add Rewritebase to redirect the framework root folder.
  2. Apparently in Rewriterule I passed the index of the framework and the parameters of controller/action.
  3. The first line I don’t know what it’s for.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.