[SOLVED] Use mod_rewrite to prettify search results

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
Guido
Forum Members
Forum Members
Posts: 221
Joined: Sat Aug 29, 2009 3:00 pm

[SOLVED] Use mod_rewrite to prettify search results

Post 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
Last edited by Guido on Fri Jul 10, 2015 4:34 pm, edited 1 time in total.
JohnnyB
Dev Team Member
Dev Team Member
Posts: 731
Joined: Tue Nov 21, 2006 5:05 pm

Re: Use mod_rewrite to prettify search results

Post 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?
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
Guido
Forum Members
Forum Members
Posts: 221
Joined: Sat Aug 29, 2009 3:00 pm

Re: Use mod_rewrite to prettify search results

Post 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.
Guido
Forum Members
Forum Members
Posts: 221
Joined: Sat Aug 29, 2009 3:00 pm

Re: [SOLVED] Use mod_rewrite to prettify search results

Post 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.
Last edited by Jo Morg on Fri Jul 10, 2015 4:39 pm, edited 1 time in total.
Reason: Please avoid auto-link of pseudo links by using "Do not automatically parse URLs" checkbox option. Thanks.
Post Reply

Return to “The Lounge”