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...
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]
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
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community