Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

SEO – How to add noindex meta tag only in beta domain in laravel blade

I’m working on a laravel blade project and my site linked with 2 domains and I want to add noindex meta tag only on beta domain.

www.example.com don’t add meta noindex tag

www.beta.example.com add meta noindex tag

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Or I just need to add noindex meta tag and this will work automatically on beta domain and not work in actuall domain.

<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>

Thanks in advance

>Solution :

A better solution is actually to use Request::getHost();

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading