Laravel Showing Index.php How can I Remove This Root htaccess
RewriteEngine On
#----------------------------------------------
# | this code use for remove public directory |
#----------------------------------------------
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ / [L,R=301]
RewriteCond %{REQUEST_URI} !(\.ico|\.css|\.js|\.png|\.jpg|\.gif|robots\.txt|\.eot|\.svg|\.ttf|\.woff|\.woff2|\.otf|\.pdf)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond %{REQUEST_URI} !^/public/uploads
RewriteRule ^(login|uploads|assets|css|js|images|ca|favicons|fonts|)/(.*)$ public// [L,NC]
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/ [L,QSA]
Public Folder htaccess
<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>
In your root .htaccess file, you need to remove the following lines:
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/ [L,QSA]
Then, in your public .htaccess file, you need to add the following line:
RewriteBase /
This should remove the index.php from the URL.
You are pointing your site to the wrong directory. You are pointing to ‘yourcoolsite’ but you should point the site to ‘yourcoolsite/public’
@teampoison where ever you setup your hosting you chose a directory to point the site to. That’s what to change.
@teampoison its called the document root and needs to point to the public folder. Instructions vary by web server type and if running something like cpanel
@Snapey site running in cpanel how can i fix it please help
@webrobert i remove index.php and public/index.php but now css not load on website
@teampoison I don’t know how else to say it. Your site points to the wrong folder. This is a common mistake. You don’t need to delete files or edit configs. Point the site to the correct folder….
-> ‘ LaravelProjectdirectoy/public’
@teampoison Why don't you just point to public as document root. Move main laravel out of web.
And this has actually been discussed here many times on how to setup laravel on shared host.
If APache, their site also has how to articles.
If Nginx, the laravel documentation covers it.
Please sign in or create an account to participate in this conversation.