• Hi,

    I try to implement CodeIgniter as ajax/database core for a WordPress portal.
    But i have some problems with ajax call to CodeIgniter url’s in subdirectory.

    server portal directory:
    /var/www/portal/

    server CodeIgniter directory:
    /var/www/portal/ci/

    server portal url:
    https://localhost/portal/

    server CI url:
    https://localhost/portal/ci/

    WordPress comes with permalinks .htaccess file like:

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

    And because i want CodeIgniter url’s without index.php i created the .htacces file like:

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

    Server CI url ,
    https://localhost/portal/ci/welcome/
    , works as expected but in an ajax call i get 404 Not Found page

    I don’t get it. Is some rules inherited from WordPress .htaccess or is something that i missed? What do you think?

    P.S. I have all the config’s for a rewriting working CodeIgniter

Viewing 6 replies - 1 through 6 (of 6 total)
  • Anonymous User

    (@anonymized-473288)

    Are you using pretty url’s in your permalinks?

    Or you don’t want this, you still want the variables in the url?

    The code you posted

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

    should show the url without index.php if you use one of the pretty url’s in the settings. See also Using Permalinks. This may help start to figure out why the Ajax call is not working. Have you tried this yet?

    In your first piece of code and second piece of code I see different paths? Have you double checked this? Or are you using two .htaccess files, one for Codeignitor and one for WordPress? .htaccess rules can inherit to subdirectories, so in my experience this can sometimes be troublesome with rewriting, till you figure out the correct rules.

    For example:

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

    Might have to be something like (pseudocode):

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

    Do you know what I mean?

    Thread Starter w3bbuilder

    (@w3bbuilder)

    @design_dolphin
    Yes, i know what you mean, but

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

    it’s giving me the host apache root.

    Indeed every application has his own .htaccess file. And of course, because wordpress is the Portal GUI Application i need to use Permalinks, and of course i have to use .htaccess.

    Codeigniter inside WordPress is one of my dream even i saw that there are a lot of solutions embedding wordpress into CodeIgniter. But i’m not agree with that solutions.

    Maybe i should use one single .htaccess, the wordpress one, but how do i format it to cover links in this form
    https://localhost/portal/ci/index.php/controller/function
    transforming them into
    https://localhost/portal/ci/controller/function/
    user friendly url’s?

    Anonymous User

    (@anonymized-473288)

    Thread Starter w3bbuilder

    (@w3bbuilder)

    As i told, everything works good in the browser. And, also ajax call it’s giving me a good Response. But actually, the response page headers from an ajax call are 404.

    I don’t want to extend WordPress thru a plugin. I know how to do that. It’s rather a question about htaccess inheritance than a wordpress and CodeIgniter join solution.

    Anonymous User

    (@anonymized-473288)

    I understand, but maybe the authors of those plugins ran into a similar problem, and from the code you might see how they solved it.

    DDT

    (@ddt)

    hi w3bbuilder,

    did you find a good solution??

    I am about to reorganize my whole setup (i am in panic).
    Setup now is
    CI root
    WP in subfolder had to add
    require_once './blog/wp-load.php';
    to index.php

    but now a major issue with sessions occurs in CI. I can’t be loggedin which my app. needs.

    So i was thinking to turn it around. WP in root and CI in sub, but before i do that i like to make sure session will work, SEO url’s/permalinks in WP will work and i am a bit clueless about the controllers.
    In my current setup i use the controller name as part of the SEO url, but if i have CI in a subfolder, subfolder becomes part of the url??
    Now the routes.php won’t work for subfolder, so i must edit the .htaccess on route level right??

    Could you share your findings solutions with CI in a subfolder???

    kind regards,

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘maybe a .htaccess problem’ is closed to new replies.