Reputation: 137
I'm having project in Laravel 6.12. I've hosted my app in live server and having SSL configured.
It works well when I access with https://example.com, but when I try to access with https://www.example.com it shows laravel's default 404 error page.
It means, it is accessing the project directory, loading css, js etc but showing 404 error page.
my .htaccess has following lines
RewriteCond %{HTTPS} =on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R,QSA,L]
Could anyone help to get rid of this?
Upvotes: 0
Views: 745
Reputation: 109
replace your .htaccess with this if try https://example.com it will force redirect to https://www.example.com This is true to SEO
RewriteCond %{HTTPS} =on
# check if not have www
RewriteCond %{HTTP_HOST} !^www\. [NC]
# force redirect to www
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Upvotes: 1