Didn't catch this on my local machine but I've noticed some of my pages returning the naked IP address of my web server instead of the domain name. Example:
route('homepage')
will sometimes return 192.XX8.X.2XX
or 192.XX8.X.2XX/index.php
or domain.com/index.php
. My pages are cached upon the first visit and there's a rough 50% chance the things will come out weird for all URLs on the page.
Is there an explanation for this weird behavior and how would I fix it? It's quite a concern since Googlebot is listing three additional duplicate copies of my site.
Note: I'm also using the LaravelLocalization package for my routes: https://github.com/mcamara/laravel-localization
I'm also running this app under Laravel Forge (Nginx)
For a start it is using a named route. This means that the link between the form and its controller are not dictated by the url that the user sees. The next advantage is that you can pass additional parameters into the route helper and it will put those in the correct place in the form action.
Named routing is another amazing feature of Laravel framework. Named routes allow referring to routes when generating redirects or Urls more comfortably. You can specify named routes by chaining the name method onto the route definition: Route::get('user/profile', function () { // })->name('profile');
The Default Route Files All Laravel routes are defined in your route files, which are located in the routes directory. These files are automatically loaded by your application's App\Providers\RouteServiceProvider . The routes/web.php file defines routes that are for your web interface.
I understand, the question is very old, but I've had same problem and found the solution. (it can help someone)
Open file RouteServiceProvider on this path: app/Providers/RouteServiceProvider.php
Look for function mapWebRoutes
. Now we have to add caller domain
with config from our environment
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->domain(\Config::get('app.url', null))
->group(base_path('routes/web.php'));
}
During building the url based on route - system tries to get local variable domain
in current route, if it found - the domain should apply immediately. But if property undefined - go to Symfony route module.
PS: Don't forget to set APP_URL
in your .env file.
Example:
APP_URL=https://mysimpledomain.ua
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With