How do you deploy site with subfolder in baseURL |
I have proposed to add .htaccess to project root.
https://github.com/codeigniter4/CodeIgniter4/pull/7676 How do you deploy a site like http://example.com/myroject/ ?
This should be added to the CodeIgniter 4 Users Guide.
There are to many different server setups out there to be able to handle all of them. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
subdomains is the approach i use ; one advantage is that you can host several sites for the same cost as hosting for one domain, if your hosting allows/has capability.
First thing is you need to edit your domain DNS to point at your hosting in order to have capability of your hosting receiving it. I do that via my "managing domains" management on hosting . I add a new domain to my hosting .Next via cPanel i go to subdomains /add on domains ,i simply point the document route to domain.org/public Ci4 as it is works for me without any further modification .
of course, this is what has been thought to come it will be a great task so but there is also one issue for the shared apps here !!
just look at here how you learn,......I put in the document root... Code: RewriteEngine On Codeigniter First, Codeigniter Then You!!
yekrinaDigitals
Yes, subdomains (no subfolder) is recommended.
Also, the user guide does not provide any instructions on how to deploy with subfolder.
I sent a PR to update the user guide.
https://github.com/codeigniter4/CodeIgniter4/pull/7680 Reviews are welcome!
Can someone review the docs?
https://github.com/codeigniter4/CodeIgniter4/pull/7680
@luckmoshy What is the one issue?
Do you recommend (2) than (1)? What's better? (1) Code: RewriteEngine On (2) Code: RewriteEngine On (07-24-2023, 06:09 PM)kenjis Wrote: @luckmoshy What is the one issue? Code: # This Check if the original request contains "/public/" (case-insensitive) Code: # This Check If the request does not already start with "/public/", add it to the beginning This RewriteRule checks if the request doesn't start with "/public/". If true, it internally rewrites the request to the "public/" subdirectory, effectively adding it to the beginning of the URL. The [L] flag stops further processing of other rules, and [NC] makes the match case-insensitive. so I recommend 2 Codeigniter First, Codeigniter Then You!!
yekrinaDigitals
I tried @luckmoshy 's config. I put .htaccess in the project root (myproject/.htaccess) folder:
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} !=on RewriteCond %{THE_REQUEST} /public/([^\s?]*) [NC] RewriteRule ^ %1 [L,NE,R=302] RewriteRule ^((?!public/).*)$ public/$1 [L,NC] </IfModule> When I navigate to http://localhost:8888/myproject/, I see the Welcome page. And when I navigate to http://localhost:8888/myproject/public/, I also see the Welcome page. There is the default .htaccess in myproject/public/. So it seems it is used and myproject/.htaccess does not used. |
Welcome Guest, Not a member yet? Register Sign In |