0

I have a live site that is going to have other URL's pointed to it with SSL. I can't seem to figure out how to have laravel redirect all incoming url traffic to its main url. If i use one of the new URL's it shows up as that url which is fine but it doesn't add SSL REDIRECT unless i actively add the Https to it. I'd prefer it to just switch over to the original APP_URL once the site responds to the URL request.

Laravel Framework 7.22.4

Ari Patwary
  • 80
  • 1
  • 8
  • 1
    Does this answer your question? [How to force Laravel Project to use HTTPS for all routes?](https://stackoverflow.com/questions/35827062/how-to-force-laravel-project-to-use-https-for-all-routes) – steven7mwesigwa Mar 15 '21 at 15:14
  • 1
    You might find this helpful [Laravel 5 - redirect to HTTPS](https://stackoverflow.com/questions/28402726/laravel-5-redirect-to-https) – steven7mwesigwa Mar 15 '21 at 15:16
  • 1
    @steven7mwesigwa Thank you for your articles I tried them both and i actually found the solution in writting a rewrite to all traffic in the htaccess file found in the public folder. now all my other domains i have pointed to the site have redirected to the site correctly! – Ari Patwary Mar 15 '21 at 18:47

1 Answers1

1

I actually found the solution:

writing a rewrite to all traffic in the .htaccess file found in the public folder. now all my other domains i have pointed to the site have redirected to the site correctly!

<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]

# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

 RewriteEngine On
 RewriteCond %{SERVER_PORT} 80
 RewriteRule ^(.*)$ https://{{ADD_URL_HERE}} [R,L]
Ari Patwary
  • 80
  • 1
  • 8