如何在laravel Blade中仅在beta域中添加noindex meta标记

k10s72fa  于 2022-11-18  发布在  其他
关注(0)|答案(1)|浏览(84)

我正在一个laravel刀片项目和我的网站与2域链接,我想添加noindex meta标记只对测试版域。
www.example.com不添加 metanoindex标记
www.beta.example.com添加 meta无索引标记
或者我只需要添加noindex meta标记,这将自动工作在测试域,而不是在actuall域工作。

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <!--Here's the Meta noindex tag-->
    <meta name="robots" content="noindex">

    <script type='application/ld+json'>
    {
        "@context": "http:\/\/schema.org",
        "@type": "WebSite",
        "@id": "#website",
        "url": "{{ route('home') }}",
        "name": "{{ config('app.name', 'Know Before You Go') }}",
        "alternateName": "Know Before You Go"
    }

    </script>

    @if(isset($seo))
        {{ $seo }}
    @else
        <title>{{ __("seo.homepage.title") }}</title>
    @endif

    <link rel='shortcut icon' type='image/x-icon' href='/favicon.ico' />

<!-- Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap" rel="stylesheet">
    <link rel="preconnect" href="https://fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css2?family=PT+Serif&display=swap" rel="stylesheet">

    <!-- Styles -->
    @vite('resources/css/app.css')

    @livewireStyles

</head>

先谢了

wtlkbnrh

wtlkbnrh1#

一个更好的解决方案实际上是使用Request::getHost();

@if (str_contains(Request::getHost(),'beta'))
   <meta name="robots" content="noindex">
@endif

相关问题