Question

I have following inside my .htaccess.

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

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

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

My public folder needs to have other public-accessible folders not related to laravel like this.

/var/laravel/public/folder1/index.html

My problem is when I access the application www.myapp.com/folder1/index.html is fine but without index.html like this www.myapp.com/folder1 doesn't work. Browser is saying "Redirect Loop".

I've also set DocumentIndex index.html in apache config but still not working. Thanks for shading a light here.

Was it helpful?

Solution

You can exclude directories from Laravel's rewrite rules by adding a rewrite rule to .htaccess like so:

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

    RewriteEngine On

    # Excluded Folders...
    RewriteRule ^(folder1|folder2|folder3|e.t.c.)($|/) - [L]

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top