htaccess: rewrite query string to path

Question!

I have a domain with the following query string:

http://example.com/?taxo=question&cata=foo&catb=bar&catc=more

My objective is to convert this query string after ?taxo= into a path based on the values for each parameter like so:

http://example.com/questions/cata/foo/catb/bar/catc/more/

Using .htaccess, this is what I've tried:

RewriteCond %{QUERY_STRING}
RewriteRule ^taxo=(.*)&(.*)=(.*)&(.*)=(.*)&(.*)=(.*)$  $1/$2/$3/$4/$5/$6/$7 [L,R=301]

However, that doesn't work for me. I'm trying to understand where I am going wrong with the RewriteRule line since the condition isn't being met.



Answers

You cannot match query string in a RewriteRule. You should use QUERY_STRING variable in a RewriteCond to match and capture value from query string:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^taxo=([^&]+)&([^=]+)=([^&]+)&([^=]+)=([^&]+)&([^=]+)=(.*)$ [NC]
RewriteRule ^/?$ /%1/%2/%3/%4/%5/%6/%7? [L,R=301]
  • Note that you will need to use %N syntax for back-reference of values captured in RewriteCond.
  • ? at the end of the target URI is to strip off previous query string.
By : anubhava


try something like this.

You need the variable accessible in both functions so it needs to be declared outside those functions and then defined inside the first one and use clearInterval() to cancel an existing interval

var timer;
$('#name').mouseenter(function() {
   timer = setInterval(mosaic, 150);
}).mouseleave(function() {
    clearInterval(timer);
});


This video can help you solving your question :)
By: admin