Create CI4 project in sub folder |
Hi !
![]() I did several research about this subject, but I didn't find a solution. I have a a domain who contains several projects. For example, I have something like this :
Now, I have tried to create a CI4 project inside a folder, like my other projects. So I put my CI4 folder (with /public, /app, /writable, etc.) inside a folder like : I want to access my project from this URL, without the index.php and without the /public folder in the URL. I think I need to create a .htaccess file at the root of the project to redirect to the /public folder (and to adapt the .htaccess file inside the /public folder), but I can't get it to work... If I don't have a .htacces in my CI4 root folder, I have a 403 Forbidden message, and if I create a .htaccess file, I always have a 500 error. Someone knows how to do that ? Thanks a lot ! ![]()
You will need to place the contents of the public folder inside codeigniter_project, and move the application elsewhere.
https://codeigniter.com/user_guide/gener..._apps.html
I have the same situation here.
I create a CI4 app in localhost with WAMP and a new VirtualHost and works correctly. But, I want to add this app in a subfolder: "C:\wamp64\www\test\app_one", where "app_one" is my project; In "app_one" I add a .htaccess with following content for the redirect to /public Code: RewriteEngine On When access "http://localhost/test/app_one/" the error is generated: Quote:404 - File Not Found In .htaccess of /public have this: Code: # If you installed CodeIgniter in a subfolder, you will need to When remove # and change to RewriteBase /test/app_one or RewriteBase /test/app_one/public the same error is generated. Can someone help me? Thanks!!!!! (04-09-2020, 11:01 AM)jreklund Wrote: You will need to place the contents of the public folder inside codeigniter_project, and move the application elsewhere. Thank you for your answer. I saw this solution but I don't want to change the structure of the project. I think there is a solution with .htaccess file but I didn't find it. I want to easily move my project without change the structure.
I'm afraid that I won't help you find such a solution, as it's incorrect and not recommended practice.
I'm not sure if this is something you can 'fix' with htaccess. Well, sure there will be any workaround about this topic but I'm not sure if that's a good practice as well.
I'm new to migrating from 3.x to 4.x, and I'm willing to do it very badly, but I also have old projects like yours that keep me from migrating. E.g., I have the following structure -- applications ----- administration ----- frontend -- admin ----- assets ----- index.php (this is for the administration app) -- assets -- uploads -- system -- .htaccess -- index.php (this is for the frontend app) I mean, how can I re-structure this kind of projects? I get it that the new style is to have the core outside the whole project and manage every application as a whole new project, which is fine. But I want to keep this structure as I showed above where I can place all those indexes into their own subfolders within the public folder. -- applications ----- administration ----- frontend -- public ----- admin -------- assets -------- .htaccess -------- index.php (admin) ----- assets ----- index.php (this is for the administration app) -- system After experimenting with CI4 I couldn't correctly call to the sub-applications into their own 'index wrapper'. After I edit the Paths.php and each index.php assigning them their correct path, all I get is new production error. I tried fixing my namespaces (which has nothing to do since the Autoload.php already have the App namespace wildcard on the PSR-4 array) Any guess my dear community? Thank you in advance. (06-04-2020, 03:56 PM)meta Wrote: I'm not sure if this is something you can 'fix' with htaccess. Well, sure there will be any workaround about this topic but I'm not sure if that's a good practice as well. Hi, Thank you for your answer. I understand your problem but I think you need to create your own topic. You don't have the same problem. You need to manage multi application projects. I guess you have already seen the page? https://codeigniter4.github.io/userguide..._apps.html Can you try to use subdomain like admin.website.com? (06-04-2020, 10:23 PM)jean5769 Wrote:(06-04-2020, 03:56 PM)meta Wrote: I'm not sure if this is something you can 'fix' with htaccess. Well, sure there will be any workaround about this topic but I'm not sure if that's a good practice as well. Hello. Actually, it is the same issue. What you need is just to make those folders, insert the index.php with its own .htaccess each and point to the right app that might be laying within the very same domain (or anywhere accesible within your server). Your approach is even more accesible given you want to have every dependency folder independent on its own folder 'wrapper' let's call it. I have seen the documentation and followed every step I could find about this multi app project, but didn't find anything. I just find similarities in the process with your request and didn't want to start a new topic on that, considering that we might be pursuing the same solution. (04-09-2020, 09:38 AM)jean5769 Wrote: Hi ! I might be late to answer this, Imma playing with CI4 recently, was stuck with the same problem and got the initial solution for the same, You do not have to change anything in the .htaccess file inside the public folder, all you have to do is create a new htaccess in root and paste the below code Code: #installpl is my subfolder
You need to change app/Config/Paths.php and also if you use spark you need to edit that file and change the path.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |