Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sharifur/6d0bb03ae79803c22a716e3cf928d4a1 to your computer and use it in GitHub Desktop.
Save Sharifur/6d0bb03ae79803c22a716e3cf928d4a1 to your computer and use it in GitHub Desktop.
canonical url generate for laravel
function canonical_url()
{
if (\Illuminate\Support\Str::startsWith($current = url()->current(), 'https://www')) {
return str_replace('https://www.', 'https://', $current);
}
return str_replace('https://', 'https://www.', $current);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment