Problem in Url Friendly

1

I'm here with another problem regarding this line

RewriteRule ^([a-zA-Z-0-9-_]+)$ index.php?controller=estabelecimentos&option=tipo&tipo=$1 [L]

Hardware htaccess

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^comer$ index.php?controller=comer
RewriteRule ^dormir$ index.php?controller=dormir
RewriteRule ^comprar$ index.php?controller=comprar
RewriteRule ^servicos$ index.php?controller=servicos
RewriteRule ^lazer$ index.php?controller=lazer
RewriteRule ^o-que-visitar$ index.php?controller=o-que-visitar
RewriteRule ^contactos$ index.php?controller=contactos
RewriteRule ^login$ index.php?controller=login
RewriteRule ^([a-zA-Z-0-9-_]+)$ index.php?controller=estabelecimentos&option=tipo&tipo=$1 [L]
RewriteRule ^([a-zA-Z-0-9-_]+)$ index.php?controller=ver_estabelecimento&option=tipo&tipo=$1 [L]

I have in the route establishments the url to be provided thus link I wanted to create another equal rule but to see the establishment corresponding to the traditional category but stay in an equal url link I made a rule equal to the establishments, but to the file view_establishment and always falls in the establishment rule.

    
asked by anonymous 11.02.2015 / 17:33

1 answer

1

You can not use exactly the same pattern twice because apache will only consider the first one. You can add /ver (or something like) at the end of the URL to differentiate the operation.

Ex:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(comer|dormir|comprar|servicos|lazer|o-que-visitar|login)$ index.php?controller=$1 

RewriteRule ^([a-zA-Z-0-9-_]+)$ index.php?controller=estabelecimentos&option=tipo&tipo=$1 
RewriteRule ^([a-zA-Z-0-9-_]+)/ver$ index.php?controller=ver_estabelecimento&option=tipo&tipo=$1

With this last rule, the URL http://exemplo.pt/[TIPO]/ver will load index.php?controller=ver_estabelecimento&option=tipo&tipo=[TIPO]

    
11.02.2015 / 18:49