redirect By htaccess with querys

0

I currently have this type of URL and it works fine:     www.example.com/flower

The full path of the example is:

www.example.com/indexmodelo.php?carpeta=flower

But previously the route was conformed through the IP instead of the FOLDER:

www.example.com/indexmodelo.php?IP=202

What I need to achieve is that when you write the current URL:

www.example.com/indexmodelo.php?carpeta=flower

Or the previous URL:

www.example.com/indexmodelo.php?IP=202

I'm going to the final URL:

www.example.com/flower

Currently in my .htaccess file says:

RewriteEngine on
Options -MultiViews

RewriteCond %{THE_REQUEST} \s/indexmodelo\.php\?carpeta=([0-9a-zA-Z_\-&=]+)\s [NC]
RewriteRule ^ /%1? [R=301,L]

RewriteRule ^([0-9a-zA-Z_\-&=]+)$ /indexmodelo.php?carpeta=$1 [L]

And I can not find a way to solve it. THANK YOU!

    
asked by Fernando 24.09.2018 в 17:19
source

1 answer

0

In the code $ 1 represents a retro-reference to the first non-passive group, that is: the value found with the regular expression in parentheses. In your case: $ 1 captures the "flower".

<ifModule mod_rewrite.c>
RewriteEngine On

RewriteRule ^indexmodelo/([0-9a-zA-Z_]+)/$  indexmodelo.php?carpeta=$1

</ifModule>

Remark: certain code editors, notably Dreamweaver, transform .htaccess into another type of file, and it does not work.

    
answered by 24.09.2018 в 18:32