Have a standard WP page that works as a search page for some custom data (data from tables that are outside WP). Currently the url is like this "/search/?q=[query]". For example "/search/?q=digital-point". We need help change the url structure to "/search/[query]". For example "/search/digital-point/". Note that the search isn't related to standard WP search. The query is handled completely by the /search/ page. PM if this is something you can do. Include your price and turnaround time (I assume you can fix this by sending us some code to paste into the child theme functions.php). Thanks, Mads
This is fixed by adding a couple lines into .htaccess Not functions.php On my phone, so can't provide code, but it should take less than 5 minutes
Wish you were not on you phone then Feel free to PM when you are in front of the computer (I assume the .htaccess fix will only affect the /search/ page and not all the other pages/posts).
We are soon moving to an nginx based VPS, so a .htaccess solution might not be the best approach (since nginx doesn't use .htaccess files). Because of nginx, we prefer a code block we can paste into our child theme functions.php
Hi Mads, You can fix it yourself in WP, in login panel you have a permalink option from there set your url as you require. Not needed to pay for that which you can fix yourself in seconds.
Please let me know if you have used wp_redirect and still did not get solution? function fb_change_search_url_rewrite(){if( is_search()&&! empty( $_GET['s'])){ wp_redirect( home_url("/search/"). urlencode( get_query_var('s')));exit();}} add_action('template_redirect','fb_change_search_url_rewrite');
It is also possible via htacces rules, but the source is an example for custom solutions on an redirect. RewriteCond%{QUERY_STRING} \\?s=([^&]+)[NC] RewriteRule^$ /search/%1/?[NC,R,L]
Thanks a lot for the code. It's not a WP search, so it's not caught by is_search() + there is no query_var "s". I can catch that we are on the /search/ page like this: if(strpos(get_permalink(), "/search/") !== false) Problem is that we don't stay on the /search/query/ page. Instead things are automatically redirected to the closest match by something in WP.