Page 1 of 1
[SOLVED] Use mod_rewrite to prettify search results
Posted: Sun Jun 14, 2015 9:22 am
by Guido
I currently have a setup where I use the seach module as it is meant to, and also as a tagging module (meaning I use tags on product pages, blog pages etc, that are links to a search result page where the search result is that tag).
I use the GET method of the search module, and use a dedicated landing page so that my results come into the URL
Code: Select all
http://mydomain.com/searchresults.html?mact=......etc
Now id like to use mod-rewrite to rewrite this URL to
Code: Select all
http://mydomain.com/searchresults/[searchterm]
So that you can share easy links with people and probably it will enhance SEO. But I'm no mod-rewrite hero. Does anyone know how this should be done using the rewriteCond and rewriteRule?
Thanks in advance,
Guido
Re: Use mod_rewrite to prettify search results
Posted: Fri Jun 19, 2015 1:44 pm
by JohnnyB
Hi,
Can you share the full path structure that is used now in the URL? Also, are you using a search tag or just hardcoded links? And, do you have mod_rewrite working for regular pages?
Re: Use mod_rewrite to prettify search results
Posted: Fri Jun 19, 2015 1:53 pm
by Guido
Hey Johnny
At the moment my URL structure's like this:
Code: Select all
searchresults.html?mact=Search%2Ccntnt01%2Cdosearch%2C0&cntnt01returnid=51&cntnt01searchinput=%20[SEARCHTERM]&submit=Versturen&cntnt01origreturnid=22
I use mod-rewrite, fully functioning. Right now I use hardcoded links in my templates, but I'm thinking about replacing these with {module action} links and using the 'urlparam' option.
Re: [SOLVED] Use mod_rewrite to prettify search results
Posted: Fri Jul 10, 2015 4:38 pm
by Guido
I found a very handy tool for this:
http://www.generateit.net/mod-rewrite/index.php
My rewriterule is now as follows:
Code: Select all
RewriteRule ^tags/([^/]*)\.html$ /zoekresultaten.html?mact=Search\%2Ccntnt01\%2Cdosearch\%2C0&cntnt01returnid=51&cntnt01searchinput=$1&submit=Versturen&cntnt01origreturnid=22 [L]
Placed
directly below "rewriteengine on". I can now share links like this:
http://www.mydomain.com/tags/[SEARCHTERM].html and you'll end up on the search results page for the searchterm provided in the URL. I'll also start building a dynamic search-sitemap, based on the most commenly used search terms from the search module. Will post this when done.