Skip to content

Instantly share code, notes, and snippets.

@m5lil
Last active January 14, 2019 20:21
Show Gist options
  • Save m5lil/54e8ba1886cb3de3f5195776d1579df2 to your computer and use it in GitHub Desktop.
Save m5lil/54e8ba1886cb3de3f5195776d1579df2 to your computer and use it in GitHub Desktop.
redirect to public folder

Method 1

index.php in public_html

<?php
$uri = urldecode(
    parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
    return false;
}
require_once __DIR__.'/public/index.php';

method 2

htaccess in public_html

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>
	
    RewriteEngine On
    RewriteBase / 
    
    RewriteCond %{HTTP_HOST} !^www\.domain\.com
    RewriteRule (.*) http://www.domain.com/$1 [L,R=301]
    RewriteRule ^(.*)$ main/public/$1 [L]
    
</IfModule>

Method 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment