
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
- Laravel create default admin user
- How to disable timestamps in laravel
- Display first n record from collection in laravel view
- Calculate age from date of birth in Laravel
- Display success message in laravel
- Laravel create multiple records in Pivot table
- PhpMyAdmin - Error The mysqli extension is missing
- Convert input array to comma-separated string in laravel controller
- How to get route name on visit URL in laravel
- How to get list of all views file in laravel
- How to get user information using hootlex/laravel-friendships package in laravel
- Automatically remove records using Prunable trait in Laravel
- How to use more than one query scope in Laravel
- Laravel recursive function in controller
- Rename Pivot Table in Laravel
- How to get last month records in Laravel
- Add a subselect based on relationship using withAggregate method
- Target class [admin] does not exist.
- How to check if user has created any post or not in laravel
- Generate unique username in Laravel
- Laravel file size validation not working
- How to use bootstrap pagination in laravel 8
- Cast Array to an Object in Controller and then pass to view in laravel
- How to get tomorrow and yesterday date in laravel
- How to add foreign key in laravel using migration