How to validate URL with https using regex in laravel

You can validate URL in laravel by creating a regex. You can create your own regex and use regex rules to validate the URL in laravel.

Answers 1
  • Laravel URL validation with https using regex

    //Inside controller's method
    $regex = '/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/';
    $request->validate([
        'url' => 'required|regex:'.$regex,
    ]);
    
    0
  • Back to code snippet queries related laravel