2017 © Pedro Peláez
 

library laravel-trailing-slash

Adds redirection with trailing slash in Laravel.

image

fsasvari/laravel-trailing-slash

Adds redirection with trailing slash in Laravel.

  • Friday, April 20, 2018
  • by fsasvari
  • Repository
  • 2 Watchers
  • 20 Stars
  • 4,657 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 12 Versions
  • 20 % Grown

The README.md

Laravel Trailing Slash

Adds url formatting and redirection with trailing slash to Laravel framework versions 12.x, 11.x, 10.x, 9.x, 8.x, 7.x, 6.x and 5.x., (*1)

Build For Laravel Latest Stable Version Latest Unstable Version Total Downloads License, (*2)

Compatibility Chart

Laravel Trailing Slash Laravel PHP
7.x 12.x 8.2+
6.x 11.x 8.2+
5.x 10.x 8.1+
4.x 9.x 8.0.2+
3.x 8.x 7.3+/8.0+
2.x 7.x 7.3+
1.x 6.x 7.2+
0.3.x 5.7-5.8 7.1.3+
0.2.x 5.6 7.1.3+
0.1.x 5.5 7.0.0+

Installation

Step 1: Install package

To get started with Laravel Trailing Slash, use Composer command to add the package to your composer.json project's dependencies:, (*3)

composer require fsasvari/laravel-trailing-slash

Or add it directly by copying next line into composer.json:, (*4)

"fsasvari/laravel-trailing-slash": "7.*"

Step 2: Service Provider

If you are using Laravel 11.x and above, register the LaravelTrailingSlash\RoutingServiceProvider in your bootstrap/providers.php configuration file:, (*5)

return [
    // Package Service Providers...
    // ...
    LaravelTrailingSlash\RoutingServiceProvider::class,
    // ...
],

If you are using Laravel 10.x and below, register the LaravelTrailingSlash\RoutingServiceProvider in your config/app.php configuration file:, (*6)

'providers' => [
    // Application Service Providers...
    // ...

    // Package Service Providers...
    // ...
    LaravelTrailingSlash\RoutingServiceProvider::class,
    // ...
],

Step 3: .htaccess

If you are using apache, copy following redirection code from public/.htaccess to your own project:, (*7)

<IfModule mod_rewrite.c>
    # Redirect To Trailing Slashes If Not A Folder Or A File...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(/$|\.)
    RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
</IfModule>

Step 4: Routes

In routes/web.php, you must use routes with trailing slashes now:, (*8)

Route::get('/', function () {
    return view('welcome');
});

Route::get('about/', function () {
    return view('about');
});

Route::get('contact/', function () {
    return view('contact');
});

Usage

Every time you use some Laravel redirect function, trailing slash ("/") will be applied at the end of url., (*9)

return redirect('about/');

return back()->withInput();

return redirect()->route('text', ['id' => 1]);

return redirect()->action('IndexController@about');

Change log

Please see CHANGELOG for more information what has changed recently., (*10)

Notice

There is a problem with overriding Laravel Paginator and LengthAwarePaginator classes. So, every time you use paginate() method on your models, query builders etc., you must set current path for pagination links. Example:, (*11)

$texts = Text::where('is_active', 1)->paginate();
$texts->setPath(URL::current());

$texts->links();

Licence

MIT Licence. Refer to the LICENSE file to get more info., (*12)

Author

Frano Šašvari, (*13)

Email: sasvari.frano@gmail.com, (*14)

Buy me a Beer

Buy me a Beer, (*15)

The Versions

20/04 2018

0.1.x-dev

0.1.9999999.9999999-dev https://github.com/fsasvari/laravel-trailing-slash

Adds redirection with trailing slash in Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Frano Sasvari

laravel php redirect

20/04 2018

v0.1.12

0.1.12.0 https://github.com/fsasvari/laravel-trailing-slash

Adds redirection with trailing slash in Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Frano Sasvari

laravel php redirect

20/04 2018

dev-master

9999999-dev https://github.com/fsasvari/laravel-trailing-slash

Adds redirection with trailing slash in Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Frano Sasvari

laravel php redirect

20/04 2018

0.2.x-dev

0.2.9999999.9999999-dev https://github.com/fsasvari/laravel-trailing-slash

Adds redirection with trailing slash in Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Frano Sasvari

laravel php redirect

20/04 2018

v0.1.11

0.1.11.0 https://github.com/fsasvari/laravel-trailing-slash

Adds redirection with trailing slash in Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Frano Sasvari

laravel php redirect

20/04 2018

v0.2.0

0.2.0.0 https://github.com/fsasvari/laravel-trailing-slash

Adds redirection with trailing slash in Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Frano Sasvari

laravel php redirect

18/04 2018

v0.1.10

0.1.10.0 https://github.com/fsasvari/laravel-trailing-slash

Adds redirection with trailing slash in Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Frano Sasvari

laravel php redirect

18/04 2018

v0.1.9

0.1.9.0 https://github.com/fsasvari/laravel-trailing-slash

Adds redirection with trailing slash in Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Frano Sasvari

laravel php redirect

18/12 2017

v0.1.8

0.1.8.0 https://github.com/fsasvari/laravel-trailing-slash

Adds redirection with trailing slash in Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Frano Sasvari

laravel php redirect

01/12 2017

v0.1.7

0.1.7.0 https://github.com/fsasvari/laravel-trailing-slash

Adds redirection with trailing slash in Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Frano Sasvari

laravel php redirect

28/07 2017

v0.1.6

0.1.6.0 https://github.com/fsasvari/laravel-trailing-slash

Adds redirection with trailing slash in Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Frano Sasvari

laravel php redirect

27/07 2017

v0.1.5

0.1.5.0 https://github.com/fsasvari/laravel-trailing-slash

Adds redirection with trailing slash in Laravel.

  Sources   Download

MIT

The Requires

 

by Frano Sasvari

laravel php redirect