1
In Laravel it is very common to use friendly URL and also very easy to use. The system is already ready for this.
However, I have a problem that so far has not mattered. And now I want to know why.
I have a simple route to all my pages:
Route::controller('/', 'FrontendController');
Then in the Frontendcontroller.php I have the call from my pages:
public function getProdutos(){ }
public function getServicos(){ }
public function getDownload(){ }
So if I type:
http://localhost/project/products
http://www.dominio.com.br/produtos
Enters the page normally.
But if I type:
http://localhost/project/products/
http://www.dominio.com.br/produtos/
He doesn’t go in and redirect to:
http://localhost/products
NOT FOUND
The problem is when you put that /
at the end. No bar works.
.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Homecontroller.php
# Contato
public function getContato(){
return view('frontend.contato');
}
# Trabalhe Conosco
public function getTrabalheConosco(){
return view('frontend.trabalhe');
}
# Serviços
public function getServicos(){
return view('frontend.servicos');
}
# Quem Somos
public function getQuemSomos(){
return view('frontend.agencia');
}
the problem is that the user can still insert the bar directly at the end of the url.
– Daniel Omine
@Danielomine As far as I understand it is exactly what the AP wants. Want it to be accessible with bar and without bar at the end.
– Guilherme Nascimento