我正在尝试在Laravel 5.1中创建一个适用于通用固定链接的路由。
Route::get('{generic_url}.html', 'Frontend\CMSController@generic');
当我访问网址时说/this-is-my-page.html我得到的404页面并非源自Laravel(我的自定义404页面未显示)。但是,当我去/index.php/this-is-my-page.html时,一切正常。
我认为这个问题源于服务器的配置。我的.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]
</IfModule>
由于我仍在开发此解决方案,因此我使用php -S localhost:8000
命令启动Web服务器。这可能是我问题的原因吗?默认配置有问题吗?我应该将我的开发转移到“真正的”服务器吗?