Rewriting URLs for Results Pages
2 posts by 2 authors in: Forums > CMS Builder
Last Post: December 15, 2010 (RSS)
Hello Again!
I hope you all are enjoying the holidays!
We came across this post about creating custom links for the details pages of our listings. And the solution works wonderfully. We are very excited.
http://www.interactivetools.com/forum/gforum.cgi?post=75851;search_string=mod%20rewrite;#75851
But now we want to take it a step further and have similar urls for our search results pages. Would this method of "custom links" be the same for the results page url, as it would be for the details?
For example, our details pages will now have a url similar to this.
http://www.rentittoday.com/viewers/costume_rentals_details.php/Christmas/CO/Beaverton/Reindeer%20Costume%20Rental,%20Beaverton,%20Oregon/38
With the details page name (which we will rewrite in our .htaccess to simply costume-rentals), subcategory, state, city, name of listing, item num.
We would like our results page to say something like
http://www.rentittoday.com/viewers/costume_rentals_results.php/subcategory/state/city
The chunks of url would change depending on what search form elements they utilized. So if they only filled out subcategory, only the subcategory would display in the url, not the state and city. We are using a function already to eliminate unused search form fields from the url.
I have read your online documentation about the SEO Urls and how it would say "/size-xl/color-blue". But is it possible to have it even cleaner and just say "xl/blue"?
Also another one of my concerns is that we use the "cities_serviced_keyword" in our cities serviced field, which enables our users to enter all the cities that they service and we do not want this to change. So would this new structure be able to keep that functionality? And if so how do begin to go about it?
Thanks!
I hope you all are enjoying the holidays!
We came across this post about creating custom links for the details pages of our listings. And the solution works wonderfully. We are very excited.
http://www.interactivetools.com/forum/gforum.cgi?post=75851;search_string=mod%20rewrite;#75851
But now we want to take it a step further and have similar urls for our search results pages. Would this method of "custom links" be the same for the results page url, as it would be for the details?
For example, our details pages will now have a url similar to this.
http://www.rentittoday.com/viewers/costume_rentals_details.php/Christmas/CO/Beaverton/Reindeer%20Costume%20Rental,%20Beaverton,%20Oregon/38
With the details page name (which we will rewrite in our .htaccess to simply costume-rentals), subcategory, state, city, name of listing, item num.
We would like our results page to say something like
http://www.rentittoday.com/viewers/costume_rentals_results.php/subcategory/state/city
The chunks of url would change depending on what search form elements they utilized. So if they only filled out subcategory, only the subcategory would display in the url, not the state and city. We are using a function already to eliminate unused search form fields from the url.
I have read your online documentation about the SEO Urls and how it would say "/size-xl/color-blue". But is it possible to have it even cleaner and just say "xl/blue"?
Also another one of my concerns is that we use the "cities_serviced_keyword" in our cities serviced field, which enables our users to enter all the cities that they service and we do not want this to change. So would this new structure be able to keep that functionality? And if so how do begin to go about it?
Thanks!
Jason Glass
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?
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
Chris