Rewriting URLs for Results Pages

2 posts by 2 authors in: Forums > CMS Builder
Last Post: December 15, 2010   (RSS)

Re: [rentittoday] Rewriting URLs for Results Pages

By Chris - December 15, 2010

Hi rentittoday,

So you want your search URLs to look like search.php/value/value instead of search.php/key-value/key-value ?

Using customized search URLs is definitely possible, but will take some serious customization. I can think of three things you'll need to change:

1. Your search forms will need to direct users to URLs with your new structure. Browsers can construct query strings (e.g. ?size=xl&color=blue) or POST form data (which doesn't show up in URLs at all,) but can't do anything else, so you'll either need to use JavaScript to override form submission and build the URLs or generate explicit redirects (either with mod_rewrite's [R] or PHP) to redirect users from normal form requests to your customized URLs.

2. Search results pages will need to be informed about what field names they should be searching, either via a mod_rewrite rule (without [R]) or a little PHP code at the top of your pages to convert your $_SERVER['PATH_INFO'] into $_REQUEST elements.

3. If you use pagination on search result pages, you'll need to manually construct the next/prev page links to conform to your new URLs.

In summary, this is complicated, but possible.

I hope this helps! Please let me know if you have any questions.

P.S. I'm not sure I understand your concern about using "cities_serviced_keyword". Can you give some examples of what you're currently doing and why you think it might be a problem?
All the best,
Chris