
Redirect from www to non www in laravel using htaccess
You can redirect from www to non www in laravel using htaccess. Htaccess will redirect you from https://www.yourdomain.com/ to https://yourdomain.com/ using RewriteCond %{HTTP_HOST} www.yourdomain.com RewriteRule (.*) http://yourdomain.com/$1 [R=301,L] in your htaccess file.
Answers 1
-
Redirect from www to non www using htaccess file in laravel 8
--PATH .htaccess<IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews -Indexes </IfModule> RewriteEngine On # Handle Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} (.+)/$ RewriteRule ^ %1 [L,R=301] # Handle Front Controller... RewriteCond %{HTTP_HOST} www.yourdomain.com RewriteRule (.*) http://yourdomain.com/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule>
0You have to add the below code in your htaccess file
RewriteCond %{HTTP_HOST} www.yourdomain.com
RewriteRule (.*) http://yourdomain.com/$1 [R=301,L]Replace with your domain name in above code.
This code snippet is working in my case.
Random Code Snippet Queries: Laravel
- Target class [admin] does not exist.
- Method Illuminate\Database\Eloquent\Collection::appends does not exist
- Print query in laravel
- Redirect to another view from controller in laravel
- Call to undefined method Illuminate\Support\Facades\Request::all()
- How to get last year records count with month wise in Laravel
- Class "App\Http\Controllers\Auth\Verified" not found
- Laravel 5.4 save data to database
- Touch parent updated_at in Laravel
- Get products with number of orders in Laravel
- Insert data with form validation using ajax in laravel
- How to get date from created_at field in laravel
- Argument 1 passed to App\Http\Controllers\Auth\LoginController::authenticated() must be an instance of App\Http\Controllers\Auth\Request
- Laravel recursive function in controller
- Send post data from controller to view
- Save or update pivot table data with additional column in Laravel
- Update record after find method in lavavel
- Get comma separated email from input array
- SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'posts_user_id_foreign'; check that column/key exists
- How to insert dynamic value to additional column in pivot table in laravel
- Rendering HTML from database table to view in Laravel
- Laravel insert query not working
- How to avoid duplicate entries in pivot table in Laravel
- How to insert multiple rows in mysql using loop in laravel?
- Get count of filter data, while return a small set of records