2015-02-23 109 views
1

example.comDocumentRoot/var/www/html中。如何設置Apache以運行基於子路徑的Laravel?

Laravel安裝在/var/www/example/public,我可以用它訪問http://example.com/dashboard但是當我試圖訪問像其他途徑爲http://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 [email protected] 
    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> 

回答

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> 
相關問題