Support the ongoing development of Laravel.io →
Configuration Laravel Architecture

I have Laravel set up and running fine on example.com. Now, I want to proxy redirect example.com/ to http://127.0.0.1:8080/ except /sitemap, /assets/, /auth/. Here the .htaccess I am using for this--

    <IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On
    
    RewriteCond %{REQUEST_URI} !^(assets|auth|sitemap) [NC]
    RewriteRule ^(.*)$ http://127.0.0.1:8080/$1 [P]
    
    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
    # make all request https
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

    RewriteCond %{HTTPS} !on
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

But it redirecting all urls including /sitemap, /assets/, /auth/.

Can anyone please help...

Last updated 3 years ago.
0

Try adding another rewrite condition:

RewriteCond %{HTTP_HOST} ^example.com$ RewriteCond %{REQUEST_URI} !^(assets|auth|sitemap) [NC] RewriteRule ^(.*)$ http://127.0.0.1:8080/$1 [P]

0

Still not working! Here is the code: ---

RewriteCond %{HTTP_HOST} ^example.com$ 
RewriteCond %{REQUEST_URI} !^(assets|auth|sitemap) [NC] 
RewriteRule ^(.*)$ http://127.0.0.1:8080/$1 [P]

When I try to load example.com/sitemap which is Laravel route, It takes me to my Node app running on http://127.0.0.1:8080

Last updated 6 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Jonson who-jonson Joined 10 Dec 2018

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.