简体   繁体   中英

Installing CodeIgniter4 inside Wordpress

So i want to add a crud system with CI4 to an existing wordpress site. So I moved my CI4 inside my website root folder. Looks like this

--web (root folder)
|
 --wp-admin
 --wp-content
 --project (CI4 folder)
 |
  --App
  --...

The problem is I cant access the project. It supposed to be in mywebsite.com/project (right?). The page says

403 Forbidden
You don't have permission to access this resource.

I already change the following line in App.php in project/app/config

public $baseURL = 'mywebsite.com/';

So I search about this problem and found out few articles about wordpress .htaccess prevent this. I tried to change the .htaccess in wordpress from

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

to this one

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

but i realize that ci4 dont have index.php in the main folder anymore.

so my questions are:

  1. For the ci4 configuration, what i need to change in ci4 files other than the line in app.php above?
  2. For the 404 Forbidden problem (I'm guessing it has something to do with .htaccess)
  3. Any suggestions to make this work, even if it has nothing to do with the .htaccess

a briefly explanation will help too. Thanks!

I hope this will help you. Just move the index.php and the .htaccess file in the public folder to ci4 root folder and then open the index.php file and edit this line

require realpath(FCPATH . '../app/Config/Paths.php') ?: FCPATH . '../app/Config/Paths.php';

To

require realpath(FCPATH . './app/Config/Paths.php') ?: FCPATH . './app/Config/Paths.php';

I hope this help else call my attentions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM