0
On htacess:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule ^blog/(.*)/$ blog/assuntos.php?disciplina=$1
RewriteRule ^blog/(.*)/(.*)$ blog/pagina.php?disciplina=$1&assunto=$2
The urls:
http://localhost/teste.com/blog/portugues/
http://localhost/teste.com/blog/geografia/mundo
On the pages:
$disciplina=$_GET['disciplina'];
$assunto=$_GET['assunto'];
Problem:
With these rules I can get the second url but not the first, the first is returning php subjects. in the $_GET['assunto'];
. I wanted the first to return at $_GET['disciplina'];
.
When I remove one of the rules the other works perfectly, but with both gives conflict. Someone knows what may be happening?
Perfect. Only the [L] already worked ,I did not know it. I’ll hit the rest also to be more straight. Thanks!!!
– Rod
@Rod would probably work even with the
[L]
because in order of interpretation the module itself must prioritize the most approximate rule of the current URL, but the problem is that a user write Urls with several bars (at least theoretically it would marry the regex)– Guilherme Nascimento
@Rod Take the opportunity to learn the basics of . htaccess for rewrites: https://answall.com/q/102722/3635 Many people usually make a living from copying codes around without understanding why, understanding the basic principles will save you a lot of heartache
– Guilherme Nascimento
I will give a read, bought book, course, but it is very difficult regex. Right now I’m trying to put an optional /? at the end of each url and will not. Oh sick thing. rs
– Rod
@Rod regex use the basics for now, but learn the mod_rewrite of Apache (.htaccess) which is key to avoiding some problems :)
– Guilherme Nascimento