Redirect from www to non www in laravel using htaccess
Redirect from www to non www in laravel using htaccess
In this session, we’ll try our hand at solving the "Redirect from www to non www in laravel using htaccess" puzzle by using the computer language.
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.-
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>
You 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.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- How to use more than one query scope in Laravel
- How to authenticate admin users in Laravel ?
- How to add background image to div using Tailwindcss, Vite in Laravel Environment
- How to set column as primary key in Laravel model
- How to create project_user pivot table in laravel
- Display message with session flash using bootstrap alert class in laravel
- Class 'Facade\Ignition\IgnitionServiceProvider' not found
- Update existing pivot table data in laravel
- Laravel get count with where condition
- Redirect to another view from controller in laravel
- How to insert value to additional columns in pivot table in laravel
- Laravel csrf token mismatch for ajax POST Request
- Get ids in array from users table
- Remove several global scope from query
- Extract only time from datetime in laravel
- Create project table with model and migration
- Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.0"
- In order to use the Auth::routes() method, please install the laravel/ui package
- Get all users except the followings users in overtrue laravel-follow
- Show old value while editing the form in Laravel
- Syntax error or access violation: 1072 Key column 'role_id' doesn't exist in table (SQL: alter table `users` add constraint `users_role_id_foreign` foreign key (`role_id`) references `roles` (`id`))
- How to remove package from laravel
- SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel8.projects' doesn't exist
- Ignore Records where a field has NULL value in Laravel
- Convert input array to comma-separated string in laravel controller