
How to prevent host header attack in Laravel
You can prevent host header attack in Laravel. You have to simply implement provided code snippet in boot method of AppServiceProvider class. It will prevent host header attack in Laravel application.
Answers 1
-
Prevent host header attack using PHP script in Laravel
$allowed_host = array('www.w3codegenerator.com'); if (!isset($_SERVER['HTTP_HOST']) || !in_array($_SERVER['HTTP_HOST'], $allowed_host)) { header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request'); exit; }
0Place this code snippet in boot method of AppServiceProvider class in app\Providers\AppServiceProvider.php. You have to change the domain name as per your requirments in $allowed_host array. Different format for your domains could be like : www.w3codegenerator.com, w3codegenerator.com , subdomain.w3codegenerator.com
Random Code Snippet Queries: Laravel
- Credit card validation in laravel
- Extra Filter Query on Relationships in Laravel
- How to display a specific word from a string in laravel
- How to pass data to multiple partial view files in laravel
- Laravel form request validation
- How to get last record from object collection in laravel
- How to fetch single row data from database in laravel
- Laravel delete all rows older than 30 days
- Call to a member function pluck() on array
- How to add columns in existing table using migration in laravel
- Get laravel version
- Update existing pivot table data in laravel
- How to get laravel errors folder in views directory in laravel
- Ignore Records where a field has NULL value in Laravel
- Call to undefined method App\Models\User::follow()
- How to pass variable from controller to model in Laravel
- Rename Pivot Table in Laravel
- Method Illuminate\Http\Request::validated does not exist
- Create records using relationship in laravel
- Add [name] to fillable property to allow mass assignment on [App\Models\Project]
- How to check query string exists or not in laravel blade
- Pass variable from blade to controller Laravel
- How to check find method executed successfully in laravel
- Target class [App\Http\Controllers\Auth\Request] does not exist.
- Insert dummy data in users table Laravel