我的Laravel路线只能通过index.php看到

时间:2016-06-10 01:00:55

标签: php .htaccess mod-rewrite laravel-5.2

我已经检查过以确保我启用了mod_rewrite并重新启动了我的网络服务器。我的.htaccess看起来很好。我错过了什么?

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

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

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

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

我的虚拟主机如下:

<VirtualHost *:80>
        ServerName cms.dev
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/cms/public
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

1 个答案:

答案 0 :(得分:1)

您已经创建了.htaccess文件,但实际上并没有告诉您的虚拟主机&#34;允许&#34; .htaccess覆盖配置。换句话说,你没有启用htaccess支持。将以下内容添加到VirtualHost块以启用它:

@Component({
  selector: 'app',
  template: `
    <link rel="stylesheet" href="styles/{{ current }}">
    ...`
})
export class AppComponent {
    current = 'site1.css';
}

根据您的目录路径更改目录路径。