简体   繁体   English

Laravel-从网址中删除public / index.php

[英]Laravel - Remove public/index.php from URL

Dears, 亲爱的,

I''m new in Laravel, and am doing a personal project. 我是Laravel的新手,正在做一个个人项目。 I have a website (HTML/CSS) and inside the website, a menu in order to start using the web application (Laravel 5.5 and php7.1). 我有一个网站(HTML / CSS),并且在网站内部有一个菜单,用于开始使用Web应用程序(Laravel 5.5和php7.1)。

I uploaded my codes to the server (ubuntu 16.04 Droplet) but i'm not able to access the website without putting public/index.php 我将代码上传到服务器(Ubuntu 16.04 Droplet),但如果未将public / index.php放入,我将无法访问该网站

for example, am using the guards (admin and users), so in order to go to admin page: www.mydomain/admin and for user www.mydomain/user . 例如,我正在使用防护(管理员和用户),因此要转到管理员页面: www.mydomain/admin和用户www.mydomain/user

But am not able to access this 但无法访问此

(500 ERROR) and when i put www.mydomain/public/index.php/admin it works, even www.mydomain/public/admin is not working. (500错误),当我将www.mydomain / public / index.php / admin放上时,即使www.mydomain / public / admin也不起作用。

public/.htaccess: public / .htaccess:

Options +FollowSymLinks -Indexes 
RewriteEngine On 
RewriteCond %{HTTP:Authorization} . 
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^ index.php [L]

default-ssl.conf (using keys and https) default-ssl.conf(使用密钥和https)

<IfModule mod_ssl.c>
        <VirtualHost _default_:443>
                ServerAdmin info@ecollectionz.com
ServerName ecollectionz.com
ServerAlias www.ecollectionz.com

                DocumentRoot /var/www/html

                SSLCertificateFile      /etc/ssl/private/ef125a55e77fd883.crt
                SSLCertificateKeyFile /etc/ssl/private/private-key.key
 <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>
...

Pleae note that am using the website and the web app on same domain, so the index home page (/var/www/html) is for the website Is there any solution for this ? 请注意,该网站和该Web应用程序在同一域中使用,因此索引首页(/ var / www / html)用于该网站是否有解决方案?

是的,将此代码用于您的.htaccess https://laravel.com/docs/5.8/installation#web-server-configuration并确保在您的apache中启用mod_rewrite模块

If you don't mind to pay 19$/month i advise you to use Laravel Forge . 如果您不愿意每月支付19美元,我建议您使用Laravel Forge You can deploy unlimited Laravel apps (and other php apps) with 0 configuration. 您可以使用0配置部署无限的Laravel应用程序(和其他php应用程序)。

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

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