Home Laravel routes not working when site is loaded using reverse proxy
Reply: 0

Laravel routes not working when site is loaded using reverse proxy

user2188
1#
user2188 Published in May 20, 2018, 10:14 am

I am using reverse proxy in my project to redirect a path to a different server.

Site 1: abc.com (server 1)

Site 2: The content is stored in different server which is mapped from a sub-domain of server 1 - testsite.abc.com (server 2)

The site in the server 2 is a laravel project. Where as the site in the server 1 is a normal html site.

The apache configuration to redirect "abc.com/new-url/" to "testsite.abc.com/" using reverse proxy is:

<VirtualHost *:80>
    ServerName abc.com
    ServerAlias www.abc.com
    DocumentRoot /var/www/vhosts/abc-livesite

    <Directory /var/www/vhosts/abc-livesite>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
    </Directory>

    ProxyPreserveHost On

    <Location "/new-url/">
        ProxyPass "http://testsite.abc.com/"
    </Location>
</VirtualHost>

The laravel routes are not working for "abc.com/new-url/" without using the index.php. But laravel routes are working fine for "testsite.abc.com/".

Example:

The route - "testsite.abc.com/test-route" is working fine.

The route - "abc.com/new-url/test-route" is showing 404 not found error. But "abc.com/new-url/index.php/test-route" is working fine.

I think, here the rewrite rule to override the index.php is not working while using reverse proxy.

The .htaccess file for the site 2 is:

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

    RewriteEngine On

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

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

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

What is the reason causing this issue? Can anyone help?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.302082 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO