Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 使用htaccess在Laravel中隐藏url段(具有相同段数的路由)_.htaccess_Laravel 5_Routes - Fatal编程技术网

.htaccess 使用htaccess在Laravel中隐藏url段(具有相同段数的路由)

.htaccess 使用htaccess在Laravel中隐藏url段(具有相同段数的路由),.htaccess,laravel-5,routes,.htaccess,Laravel 5,Routes,我在web.php中有这些路由 Route::get('/book/{book}', booksController@show); Route::get('/user/{user}', UsersController@show); Route::get('/{category}', CategoriesController@show); 我想使用htaccess从url中隐藏book和user,只要它们不能在路由中删除。我在/.htaccess和/public/.htaccess中都试过,但都

我在web.php中有这些路由

Route::get('/book/{book}', booksController@show);
Route::get('/user/{user}', UsersController@show);
Route::get('/{category}', CategoriesController@show);
我想使用htaccess从url中隐藏
book
user
,只要它们不能在路由中删除。我在
/.htaccess
/public/.htaccess
中都试过,但都没有成功

RewriteEngine on
RedirectMatch 301 /book/(.*) /$1

RewriteEngine on
RewriteRule ^/book/(.+)$ /$1 [L,QSA]

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ book/$1 [L]
当我访问一个包含单词
book
的url时,它不会被删除,它总是在那里。现在,我怎么能在没有像
book
user
这样的静态单词的情况下,拥有所有三条路线,而不会像这样产生任何冲突呢

Route::get('/{book}', booksController@show);
Route::get('/{user}', UsersController@show);
Route::get('/{category}', CategoriesController@show);