from /search-query-me.html to ?s=search+query+me

Discuss practical ways rearrange URLs using mod_rewrite.

from /search-query-me.html to ?s=search+query+me

Postby montyburns » Tue Nov 04, 2008 10:32 pm

ahoy rewriters!
i've been into mod_rewrite for a ~month now and i find it useful for making urls friendly in wordpress..

and now..

my problem is this..

from search-query-me.htm to ?s=search+query+me

is it possible to replace a character ('-' to '+' like above) using only mod_rewrite or is an intermediary script needed to do the redirect?

or maybe capture only the characters and rewrite them with separators in between?

anything is much, much appreciated..

mod_rewrite RULES! :D
montyburns
 
Posts: 2
Joined: Tue Nov 04, 2008 10:23 pm

Postby richardk » Wed Nov 05, 2008 1:44 pm

Why not use + in the URL?

It's not efficient to do it with mod_rewrite, but it can be done. I would do it with your script. If it's PHP add the following to the beginning of the file
Code: Select all
if(isset($_GET['s']))
{
  $_GET['s'] = str_replace('-', ' ', $_GET['s']);
}
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby montyburns » Wed Nov 05, 2008 4:45 pm

thanx for replying richardk..

i could use + but then google only considers urls with - and _ for static pages coz we want the queries to appear like one.. the other links in the site is like that too..

hmm.. your right.. i can just replace the values in _SERVER variables from - to ' ' or + then let wp handle it..

thanx again..
montyburns
 
Posts: 2
Joined: Tue Nov 04, 2008 10:23 pm


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 3 guests

cron