Conflict RewriteRule in htaccess

0

I've done a lot of research but I did not find the solution to my problem.

I have an htaccess in the following format:

RewriteEngine On
RewriteRule fotos$ arc_fotos.php
RewriteRule fotos/$ arc_fotos.php
RewriteRule minha-area/$ arc_minha_area.php
RewriteRule minha-area/fotos$ arc_minhas-fotos.php

When I access the address mydomain.com / photos - > photo page (arc_photos) OK

But when I access the address mydomain.com / my-area / photos it goes to arc_fotos.php being that I want it to go to arc_minhas_fotos.php

The same thing happens when:

RewriteEngine On
RewriteRule blog/$ arc_blog.php
RewriteRule esqueci esqueci_senha.php

When the user accesses mydomain.com/blog/a-pagina-com-url-inesqueci he interprets in ESQUECI vel and goes to the page forget_password.php

Can anyone help me to avoid this kind of conflict?

    
asked by anonymous 21.08.2017 / 17:16

1 answer

0

To solve your problem, you should know how to analyze the specification level of your rules.

  

More specific rules should be at the top.

But how so level of specification?

The level of specification can be verified in several forms (if you want to know more piece later, I'll address only your case)

  

To know if something is more specific just check if any other rule encompasses it.

RewriteRule fotos$ arc_fotos.php # menos especifico
RewriteRule minha-area/fotos$ arc_minhas-fotos.php # mais especifico

The first rule includes the second rule because fotos$ also captures the statements of minha-area/fotos$ or the first rule is more generic making the second more specific, since for the second it is necessary to have minha-area together. / p>

Following the rule quoted above your order should then be:

RewriteRule minha-area/fotos$ arc_minhas-fotos.php # mais especifico
RewriteRule fotos$ arc_fotos.php # menos especifico
    
21.08.2017 / 18:37