简体   繁体   中英

Remove index.php from laravel site

I am very new in Laravel and by doing this I am learning a lot. But still can't figure out how the .htaccess works for Laravel 4. I have uploaded my project to a cPanel server by hostgator. I have put all of my files in home directory and public files in public_html folder and changed the path.php accordingly.

This is how my path.php looks like:

'app' => __DIR__.'/../app',
'public' => __DIR__.'/../public_html',
'base' => __DIR__.'/..',
'storage' => __DIR__.'/../public_html/storage',

Then I added this to my .htaccess file inside public_html folder:

Options -MultiViews
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

But then it takes me to hostgator's 404 page. I have tried several solutions for htaccess , but whatever I do, it takes me to 404. Can't really figure out what I am doing wrong. This also causing problem to load some assets (js, css and images) in my pages. For example, I have a img url like this:

http://IP/~dc/_img?img=/storage/pictures//141/7e31503bb62b0be8760483e0b82f46cf.jpg

Which doesn't work. Then I tried this (just the url in a browser tab):

http://IP/~dc/index.php/_img?img=/storage/pictures//141/7e31503bb62b0be8760483e0b82f46cf.jpg

This works. How can I solve this problem? Do I need to do something in the config file also? In app/config/app.php I have this:

'url' => 'http://IP/~dc',

Follow the steps shown in this link. here I have shown all the settings step by step https://stackoverflow.com/a/32746953/3975838

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM