Posts

Showing posts with the label htaccess

htcaccess redirect a page to another

I've recently came across an issue with WordPress search redirection and felt like sharing the solution. Problem: You search is going to ?s=searchText&secondParameter=secondvalue If you enable permalinks, search may start go be redirected over to /search, losing the second parameter. Using woocommerce requires the second parameter in order to show results from the store. Some considerations: - Using RewriteCond regular expressions can be retrieved later by RewriteRule with %1 - Using RewriteRule regular expressions can be retrieved right away with $1 - Output from %1 will be urldecoded. The usage of [B] is refer as a workaround (didn't work for me). - RewriteRule cannot work with query strings (getting the query string value or setting up a condition requires RewriteCond) Solution: #only catch URLs that contain the "s" query string RewriteCond %{QUERY_STRING} ^s=([^\&]*)&post_type=product$ #for the URL catched, redirect to /search/ plus t...