Trouble with 2 RewriteRule
RewriteRule ^(.)/(.)/(.*)/([0-9]+)/?$ viewauthor.php?lg=$1&cat=$2&nameauthor=$3&id=$4 [NC,L]
RewriteRule ^(.)/(.)/(.*)/([0-9]+)/?$ viewbook.php?lg=$1&cat=$2&namebook=$3&id=$4 [NC,L]
I can't access to the second rewriterule cause it's similar.
to see which page I am on. I put echo $SERVER['QUERYSTRING']; in those two page.
When I remove the flag [NC,L], I access to the second rewriterule but the lg=viewauthor.php instead lg=en.
Thanks for help
2 Replies
That said, I don't think the second rule does what you think it's supposed to do. You're using the same regex for both rules. I think you're getting "lg=viewauthor.php" because it's performing the substitution in the first rule, then running it back through the second rule and substituting again. I get the feeling this isn't what you really want. Unfortunately, I don't know exactly what your use case is supposed to be here, so it's hard to offer suggestions for a fix. It looks like you're trying to create a transparent "pretty" URL that passes parameters to an "ugly" PHP call, kind of like what MediaWiki does. (I do something similar on my site with archive URLs.) You might want to differentiate authors and books with something unique in the "pretty" URL, like this:
RewriteRule ^/authors/(.*)/(.*)/(.*)/([0-9]+)/?$ viewauthor.php?lg=$1&cat=$2&nameauthor=$3&id=$4 [NC,L]
RewriteRule ^/books/(.*)/(.*)/(.*)/([0-9]+)/?$ viewbook.php?lg=$1&cat=$2&namebook=$3&id=$4 [NC,L]