2

的 在。DocumentRoot_example.com/var/www/html

Laravel 已安装,/var/www/example/public我可以使用它来访问它,http://example.com/dashboard但是当我尝试访问其他路由时出现问题,比如 ashttp://example.com/dashboard/login并且抛出404 Not Found错误。并说The requested URL /var/www/example/public/index.php was not found on this server.有人可以指导我吗?

公共目录中的.htaccess文件保持不变。

这是000-default.conf

ServerName example.com
UseCanonicalName Off
<Directory /var/www/html/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /dashboard /var/www/example/public
    <Directory /var/www/example/public>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>
#dynamic subdomain provisioning
<VirtualHost *:80>
    DocumentRoot /var/www/example/public
    ServerName user.example.com
    ServerAlias *.example.com
    <Directory /var/www/example/public>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>
4

1 回答 1

0

我可以在文件中使用以下内容来解决000-default.conf

<Directory /var/www/example/public>
    DirectoryIndex index.php
    AcceptPathInfo on
    AllowOverride All
    Options None
    Order allow,deny
    Allow from all
</Directory>

并且必须通过以下方式更改 laravel .htaccess:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On
    RewriteBase /dashboard

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ dashboard/$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
于 2015-02-23T13:22:40.460 回答