phpnet/phpnet-laravel-trailing-slash
Composer 安装命令:
composer require phpnet/phpnet-laravel-trailing-slash
包简介
Adds redirection with trailing slash in Laravel.
关键字:
README 文档
README
Adds redirection with trailing slash in Laravel.
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:
composer require fsasvari/laravel-trailing-slash
Or add it directly by copying next line into composer.json:
"fsasvari/laravel-trailing-slash": "0.1.*"
Step 2: Service Provider
After installing the Laravel Trailing Slash library, register the LaravelTrailingSlash\RoutingServiceProvider in your config/app.php configuration file:
'providers' => [ // Application Service Providers... // ... // Other Service Providers... LaravelTrailingSlash\RoutingServiceProvider::class, // ... ],
Step 3: .htaccess
Copy following redirection code from public/.htaccess to your own project:
<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:
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.
return redirect('about/'); return back()->withInput(); return redirect()->route('text', ['id' => 1]); return redirect()->action('IndexController@about');
Licence
MIT Licence. Refer to the LICENSE file to get more info.
Author
Frano Šašvari
Email: sasvari.frano@gmail.com
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-01-10