htaccess help in coexisting Codeigniter and Wordpress install

前端 未结 3 1940
春和景丽
春和景丽 2021-01-16 05:15

My intention here is to have a codeigniter app with a blog under the same domain. The admin for both should be separate.

The directory structure is this:

<         


        
相关标签:
3条回答
  • 2021-01-16 05:49

    OK the solution is to use

    CI .htaccess

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

    and

    WP .htaccess

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

    That did the trick. Now all pages show without a problem.

    0 讨论(0)
  • 2021-01-16 05:56

    I generally use 2 sets of conditions on the CI .htaccess (one on the root folder)

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^blog/(.*)$ blog/index.php [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
    

    This will allow the processing of blog URLs first and then deal with the CI URLs. You need to be careful not to have any controllers or routes using the term blog in your application.

    0 讨论(0)
  • 2021-01-16 06:07

    I would try three things in your Wordpress .htaccess (don't touch the CI one -- it looks correct):

    First, try removing the forward slash from before your index.php:

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

    If that doesn't work, then instead, try setting the RewriteBase to /blog/:

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

    Finally, if neither of those things work, you can try manually adding "/blog/" to your index.php line at the end:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]
    </IfModule>
    # END WordPress
    
    0 讨论(0)
提交回复
热议问题