24
I created some rules in my file .htaccess
to format the display of URL, but I’m having difficulty passing the parameter to the page that shows the products and show the URL Friendly formatted, the code is like this:
RewriteEngine On
RewriteRule ^Pagina-Inicial\/?$ index.php?acessando=home [L]
RewriteRule ^institucional\/?$ index.php?acessando=institucional [L]
RewriteRule ^promocoes\/?$ index.php?acessando=promocoes [L]
RewriteRule ^lojas\/?$ index.php?acessando=lojas [L]
RewriteRule ^lojas\/?$ index.php?acessando=loja [L]
RewriteRule ^contato\/?$ index.php?acessando=contato [L]
RewriteRule ^trabalhe\/?$ index.php?acessando=trabalhe [L]
RewriteRule ^([a-z,0-9,A-Z,_-]+)$ /produtos.php?dep=$1
RewriteRule ^([a-z,0-9,A-Z,_-]+)\/([a-z,0-9,A-Z,_-]+)$ /produtos.php?dep=$1&sup=$2
RewriteRule ^([a-z,0-9,A-Z,_-]+)\/([a-z,0-9,A-Z,_-]+)\/([a-z,0-9,A-Z,_-]+)$ /detalhes.php?produto=$1&dep=$2&sub=$3
For example, when the customer clicks KITCHEN redirects to the page php products. passing the parameter and showing in URL something like this, I made an edit to try to make it clear.
When the user clicks on the main menu, today it is like this:
http://moveissaobento.com.br/msb/produtos.php?dep=1
http://moveissaobento.com.br/msb/produtos.php?dep=2
http://moveissaobento.com.br/msb/produtos.php?dep=3
I’d like to leave it at that:
http://moveissaobento.com.br/msb/COZINHA
http://moveissaobento.com.br/msb/DORMITORIO
http://moveissaobento.com.br/msb/SALA-DE-JANTAR
When the user clicks on the submenu, today it looks like this:
http://moveissaobento.com.br/msb/produtos.php?dep=1&sub=4
http://moveissaobento.com.br/msb/produtos.php?dep=2&sub=15
http://moveissaobento.com.br/msb/produtos.php?dep=3&sub=34
I’d like to leave it at that:
http://moveissaobento.com.br/msb/COZINHA/AMBIENTE-MESA-C/-BANQUETAS
http://moveissaobento.com.br/msb/COZINHA/AMBIENTE-MESA-C/-CADEIRAS
I don’t know exactly how to show URL in the friendly way.
In your PHP you already have some code to get the item ID (category, subcategory and product) through the name passed?
– André Ribeiro
Hello @Andréribeiro, I have the code that receives the department id, subdepartamento and product but not as you said, by the name passed.
– adventistapr
Another question: do you really need to pass the department id and subdepartment to open the product page? Because if you really need it you’ll have to pass the id of both in the URL somehow.
– André Ribeiro
Yes @Andréribeiro, I need to pass these id s, the way it is and what I read in some articles have as, but I could not.
– adventistapr
this bar will give conflict in the rule: ENVIRONMENT-MESA-C
/
-CHAIRS, you have to treat this for: ENVIRONMENT-TABLE-WITH-CHAIRS.– Ivan Ferrer
Related: User-friendly URL using HTACCESS
– KaduAmaral
@Kaduamaral, thanks for the excellent link, helped me a lot.
– adventistapr