jrhenderson1988 said: Is there a way I can match any domain that is not my domain or a subdomain of my domain in this way?
Yes, don't use a domain filter on the last group. Since if it makes it that far it didn't match the other routes.
I need to be able to access the domain to do something with it afterwards too, just like I did with $subdomain.
You can get the requested url domain with,
Request::getHost()
Thanks for your reply. That's what I'm doing at the moment. I was just hoping there was a way of doing it with a domain filter as it felt cleaner that way.
Thanks for the tip on Request::getHost()
. I am currently using:
Request::server('HTTP_HOST');
I know this is really late, but there is a way to do it with a domain filter. By default Laravel applies a regexp to the filter that prevents you from passing any non-alphanumeric characters. You can override this in app/Providers/RouteServiceProvider.php
in the boot
method with something like:
public function boot(Router $router)
{
$router->pattern('domain', '[a-z0-9.]+');
parent::boot($router);
}
Now you can do dynamic full domain routing just like you would subdomains.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community