简体   繁体   English

从Laravel网站删除index.php

[英]Remove index.php from laravel site

I am very new in Laravel and by doing this I am learning a lot. 我在Laravel中非常陌生,通过这样做,我学到了很多东西。 But still can't figure out how the .htaccess works for Laravel 4. I have uploaded my project to a cPanel server by hostgator. 但是仍然无法弄清楚.htaccess对于Laravel 4是如何工作的。我已将项目由hostgator上传到cPanel服务器。 I have put all of my files in home directory and public files in public_html folder and changed the path.php accordingly. 我已经将所有文件放在主目录中,将公共文件放在public_html文件夹中,并相应地更改了path.php

This is how my path.php looks like: 这是我的path.php样子:

'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: 然后,将其添加到public_html文件夹中的.htaccess文件中:

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. 但是随后,我将带到hostgator的404页面。 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. 我已经尝试了htaccess几种解决方案,但是无论我做什么,它都将我带到了404。无法真正弄清楚我做错了什么。 This also causing problem to load some assets (js, css and images) in my pages. 这也导致在我的页面中加载某些资产(js,css和图像)时出现问题。 For example, I have a img url like this: 例如,我有一个像这样的img网址:

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: app/config/app.php我有这个:

'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 这里我一步一步显示了所有设置https://stackoverflow.com/a/32746953/3975838

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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