How to change the order of the parameters of the Friendly Url in htaccess?

1

My friendly URL l looks like this: guaraparivirtual.com.br/noticias-guarapari/moqueca-capixaba-agua-na-boca/9/

I would like to have the order of place changed from the last to the last but one.

In this way: guaraparivirtual.com.br/noticias-guarapari/9/moqueca-capixaba-agua-na-boca/

I did everything but to no avail.

Follow my code for .htaccess

URL AMIGAVEL

<IfModule mod_rewrite.c>
  RewriteEngine On

  RewriteRule ^noticias-guarapari/([a-z0-9-]+)/([a-z0-9-]+)/?$ /noticias-guarapari.php?idnoticia=$2&nome=$1 [NC]
</IfModule>

I know it sounds obvious, but I've changed the order to:

 RewriteRule ^noticias-guarapari/([a-z0-9-]+)/([a-z0-9-]+)/?$ /noticias-guarapari.php?nome=$1&idnoticia=$2 [NC]

And I called the url: guaraparivirtual.com.br/noticias-guarapari/9/moqueca-capixaba-agua-na-boca/

The content of mysql does not load when this last change is made, only the first that works perfectly.

    
asked by anonymous 10.08.2017 / 06:04

1 answer

1

Let's understand the order of the parameters.

It used to be this way:

Having in order:

  • moqueca-capixaba-agua-na-boca
  • 9
  • Now you want it to look like this:

    Having in order:

  • 9
  • moqueca-capixaba-agua-na-boca
  • So it's simple, just change:

      

    name = $ 1 for name = $ 2

         

    idnoticia = $ 2 for idnoticia = $ 1

    Looking like this:

                                  # $1           $2
    RewriteRule ^noticias-guarapari/([a-z0-9-]+)/([a-z0-9-]+)/?$ /noticias-guarapari.php?nome=$2&idnoticia=$1 [NC]
    
        
    10.08.2017 / 08:52