skip to Main Content

I am facing issue "Index of /" while accessing my website that i have uploaded on cPanel direct root. Even I have .htaccess file in public_html

I try this htaccess code.

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_URI} !^/public/ 

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f



RewriteRule ^(.*)$ /public/$1 
#RewriteRule ^ index.php [L]
RewriteRule ^(/)?$ public/index.php [L] 
</IfModule>

2

Answers


  1. You need to disable indexing your paths from htaccess. Add this line to htaccess above:

    <IfModule mod_rewrite.c>
    Options +FollowSymLinks
    Options -Indexes
    
    RewriteEngine On
    
    RewriteCond %{REQUEST_URI} !^/public/ 
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    
    
    
    RewriteRule ^(.*)$ /public/$1 
    #RewriteRule ^ index.php [L]
    RewriteRule ^(/)?$ public/index.php [L] 
    </IfModule>
    
    Login or Signup to reply.
  2. <IfModule mod_rewrite.c>
        <IfModule mod_negotiation.c>
            Options -MultiViews -Indexes
        </IfModule>
    
        RewriteEngine On
    
        # Handle Authorization Header
        RewriteCond %{HTTP:Authorization} .
        RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
        # Redirect Trailing Slashes If Not A Folder...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_URI} (.+)/$
        RewriteRule ^ %1 [L,R=301]
    
        # Send Requests To Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
    </IfModule>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search