• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
htaccess for redirecting all requests to public folder in shared hosting

#1
Maybe this could be added to the framework or to documentation somewhere - or maybe who ever needs a nudge in a speedy set up will find it useful here. This is an .htaccess file which should be put where the public folder is in a shared hosting - for redirecting everything to the public  folder - since thats where the index.php file is at.

<IfModule mod_rewrite.c>
    RewriteEngine on
    # Redirect requests to public
    RewriteRule  ^$ public/    [L]
    RewriteRule  (.*) public/$1 [L]
</IfModule>
---------
UPDATE:
Too many people are looking at this thread. This can be used for your development convenience on your local host ^ Just don't use bad hosting where your not able to move your folders above public_html or configure your "project root"

Right now I do this:
- "public" folder becomes the shared hosting default "public_html" folder, or whatever your shared hosting names your project folder
- encapsulate everything (app, writable,vendor, etc.) in a folder titled "project_folder", move it up. I encapsulate it in a folder so as not to make a mess with other hosting files.
- update $pathsPath, in index.php, to  FCPATH . '../project_folder/app/Config/Paths.php';
- also line 33 in spark.php (define('FCPATH', __DIR__ . '/public' . DIRECTORY_SEPARATOR);) should be changed - but I'm not sure yet what spark does as I haven't used it yet.
- yay for good security measures

----- ON A BETTER HOSTING you can actually simply configure your "public" folder to be your "project root" - and thats it
You can see things I made with codeigniter here: itart.pro its not overly impressive as I have very little time to learn.
Reply


Messages In This Thread
htaccess for redirecting all requests to public folder in shared hosting - by Leo - 03-16-2020, 12:23 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.