Rewriterule conflict in htaccess

Asked

Viewed 71 times

0

I’ve done several searches but I haven’t found 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 meudominio.com.br/photos -> photo page (arc_photos) OK

But when I access the address meudominio.com.br/my-area/photos it goes to arc_fotos.php and I want it to go to arc_minhas_fotos.php

The same case happens when:

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

When the user accesses meudominio.com.br/blog/uma-pagina-com-url-inforgotvel he interprets inI forgotand goes to the page forgetting_password.php

Can someone help me to avoid this kind of conflict?

1 answer

0

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

The most specific rules should be at the top.

But as well as level of specification?

The level of specification can be checked from various form (if you want to know more piece later, I will address only your case)

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

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

The first rule encompasses the second because fotos$ also captures the sentence of minha-area/fotos$ or be the first rule is more generic making the second more specific, since for the second occurs it is necessary to have together minha-area.

Following the above-mentioned rule your order should then be :

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.