The function of my program is to create a subdomain/subdirectory. I have a directories table, once a user will create a subdomain it redirects to its subdomain.
Example: My site is http://dns.dev , if I will create a subdomain 'test' and click the button 'Create directory', then it redirect to http://test.dns.dev
I have this route for subdomains.
Route::post('/create', 'DirectoryController@create');
Route::group(['domain' => '{subdomain}.dns.dev'], function () {
Route::get('/', function ($subdomain) {
return $subdomain;
});
});
In my controller,
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Redirect;
use App\Directory;
class DirectoryController extends Controller
{
public function create(Request $request)
{
$directory = new Directory;
$directory->domain = $request->subdomain;
$directory->status = "pending";
$directory->save();
//redirect to $request->subdomain . '.dns.dev/'
//something like that
}
}
Try this
$url = 'http://yourdomainname.com';
return Redirect::to($url);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.