【发布时间】:2015-08-20 10:30:28
【问题描述】:
我正在尝试在我的应用程序中实现静态和动态子域路由。它没有按预期工作。我在本地机器上使用 WAMPServer。
routes.php
Route::get('/', 'WelcomeController@index');
Route::group(['domain' => 'api.letsplay.dev'], function () {
Route::group(['prefix' => 'v1'], function () {
Route::get('users', function () {
return "Success";
});
});
});
php artisan route:list 给出了这个
+------------------+----------+----------+------+----------------------------------------------+------------+
| Domain | Method | URI | Name | Action | Middleware |
+------------------+----------+----------+------+----------------------------------------------+------------+
| | GET|HEAD | / | | App\Http\Controllers\WelcomeController@index | guest |
| api.letsplay.dev | GET|HEAD | v1/users | | Closure | |
+------------------+----------+----------+------+----------------------------------------------+------------+
hosts 文件有这个
127.0.0.1 localhost
127.0.0.1 hosp.dev
127.0.0.1 letsplay.dev
我使用的是laravel框架提供的.htaccess文件,没有做任何改动
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster@letsplay.dev
DocumentRoot "c:/wamp/www/letsplay-web/public"
ServerName letsplay.dev
ErrorLog "logs/letsplay.dev-error.log"
CustomLog "logs/letsplay.dev-access.log" common
</VirtualHost>
当我尝试从浏览器中点击 letsplay.dev 时,它按预期工作。但是在尝试点击 api.letsplay.dev/v1/users 时,我在 Chrome 中得到了 ERR_ICANN_NAME_COLLISION,并从 IE 中得到了以下错误!
帮助我了解我错过了什么!
【问题讨论】:
标签: apache .htaccess laravel routing wamp