CodeIgniter Forums
How to run version 4 in a subdirectory - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: How to run version 4 in a subdirectory (/showthread.php?tid=77214)



How to run version 4 in a subdirectory - AverageGuy - 08-03-2020

I've searched for hours and found lots of suggestions, of which none worked because they all seem to be too old and don't address version 4's move of index.php to public.

Here's what I finally ended up with before I came here.  This is in my edit directory (http://example.com/edit.  I'm running it in a virtual system managed by virtualmin and the files are in ~/public_html.  Specifically ~/public_html/edit. 
Code:
~/public_html/edit$ ls -a
.   .gitignore  README.md  composer.json  license.txt       public  system
..  .htaccess   app        env            phpunit.xml.dist  spark   writable
Code:
Options +SymLinksifOwnerMatch

# RewriteEngine On
# Please do-not forget to change RewriteBase /YOUR-SUBFOLDER HERE
RewriteBase /edit

RewriteRule ^$ public/index.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)

RewriteRule ^(.*)$ public/index.php?/$1 [L]
I don't quite understand Apache directives.  This gets me to a 404 error when I visit http://example.com/edit

I know it can be done, I just can't do it.
Thanks for the help.
Jim.

I did change the public/.htaccess file too:
RewriteBase /edit


RE: How to run version 4 in a subdirectory - jreklund - 08-03-2020

Hi, take a look at this tutorial:
https://forum.codeigniter.com/thread-76777.html

And instead of /public_html/ it should be /public_html/edit

And you need ../../ instead of ../ in your index.php file.

If it dosen't work, open up your .htaccess and only change "RewriteBase /edit", everything else should be left as is.


RE: How to run version 4 in a subdirectory - AverageGuy - 08-03-2020

That works or at least it displays something reasonable. Now I just have to develop the site.

Thank you!
Jim.