laravel trailing Slashes redirect to localhost

user3213240 picture user3213240 · Feb 12, 2014 · Viewed 9.4k times · Source

When I try this

http://localhost/Testlaravel/public/users/login

it works. But when I try

http://localhost/Testlaravel/public/users/login/ 

it redirects me to

http://localhost/users/login/

Any idea why?

This my htaccess file

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

Answer

anubhava picture anubhava · Feb 12, 2014

Change your code to this:

Options -MultiViews
RewriteEngine On
RewriteBase /Testlaravel/public/

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

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