检查当前页面网址是否包含某些单词

I'm trying to find a way to make it so that you can check if your current page url contains things like 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 the problem is this format could literally go on forever and at any random time I would need to make it so that one of the numbers doesn't display.

Currently I'm using a system like this to gather the current page URL.

$d = explode('?', $_SERVER['REQUEST_URI'], 2);
echo 'http://' . $_SERVER['HTTP_HOST'] . $d[0];

However I'm unfamiliar how we could simply check the URL for certain parts and then redirect it back to the index page.

EDIT: This is my current code (Note I'm using laravel).

if (strpos($d, '19') !== false) {       
    header( 'Location: http://example.com' ) ;
} else { ?>
<form class="form-horizontal" role="form" method="POST">
    {{ csrf_field() }}
    @if( strlen( $link->password ) )
        <p class="bg-warning" style="padding: 8px;">Enter password to continue</p>
                <input type="password" name="password" class="form-control" style="margin-bottom:1.5rem;">
                    @endif
        <button type="submit" class="btn btn-primary">{{ $link->text }}</button>
</form>
<?php } ?>

Sorry for the messy code, Just trying to figure out how I can achieve this without having numerous strpos and actually have it echo out the form as right now it does not.

if you get data from url and page is like this test.php?id=1 you directly access the data using $_GET method and process them. In my case i access the dirctly $_GET["id"], its return value 1. so you directly compare value.

Thanks.

You're in luck, that feature is literally built-in to php!

<?php

echo $_GET['id']; //fetches whatever is after the id= (and before the next '&') example.com?id=WhateverComesHere

?>