PHP code example of ozkanozcan / laravel-404-to-301
1. Go to this page and download the library: Download ozkanozcan/laravel-404-to-301 library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ozkanozcan / laravel-404-to-301 example snippets
return [
// Enable or disable the redirect middleware globally
'enabled' => env('REDIRECT_404_ENABLED', true),
// Log missing 404 URLs to Laravel Log files
'log_missing' => env('REDIRECT_404_LOG_MISSING', true),
'log_channel' => env('REDIRECT_404_LOG_CHANNEL', 'daily'),
// Save missing 404 URLs to the `missing_urls` database table
'db_log_missing' => env('REDIRECT_404_DB_LOG', true),
// Default status code (301 for permanent, 302 for temporary)
'default_code' => env('REDIRECT_404_DEFAULT_CODE', 301),
// Ignore patterns to exclude static assets
'ignore_patterns' => [
'*.css', '*.js', '*.ico', '*.png', '*.jpg', '*.jpeg',
'*.gif', '*.svg', '*.webp', '*.woff2', '/favicon*', '/robots.txt',
],
// Cache TTL in seconds (0 = disabled)
'cache_ttl' => env('REDIRECT_404_CACHE_TTL', 3600),
];