Force Redirect To www htaccess Laravel; You can force a redirect to www from non-www using the htaccess file in laravel. For www redirect using the .htaccess file, you have to put some code components in your htaccess file. This code component will force redirect to www your website.
This code component will prevent non-www and force to www. This is too much important while your site running worldwide. You can also redirect from a coding script but this way is very simple and easy.
In laravel force redirect www using .htaccess goto your root directory, There, You will see a file name ".htaccess". Open this file and paste below the given code component in this file "IfModule".
RewriteEngine On
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
We always thanks to you for reading our blogs.
Dharmesh Chauhan
(Swapinfoway Founder)Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us
Haresh Chauhan
(Co-Founder)We Are Also Recommending You :
- Laravel 10 Handle Image Upload Example Tutorial
- Laravel OneSignal Push Notification Integrate
- Parent OrderBy From Many Child's Laravel Example
- groupBy() Method Laravel Collection Exmaple
- Laravel 9 Sanctum API Authentication Tutorial
- How to Install Laravel 10 With Video Tutorial
- REST API Authentication With Laravel Passport - Webappfix
- Unique violation: 7 ERROR: duplicate key value violates unique constraint "users_pkey" DETAIL: Key (id)=(1) already exists.
- How To Connect PostgreSQL With Laravel Application
- Error : Trying To Get Property Of ID Non-Object All Possible Solution Guideline In Laravel - PHP