Welcome to WebmasterWorld Guest from 52.91.39.106

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

Assistance required htaccess

A fairly complicated redirect.

     
12:42 am on Aug 23, 2003 (gmt 0)

Moderator from GB 

WebmasterWorld Administrator mack is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:June 15, 2001
posts:7833
votes: 90


I just can't seam to get my head around this.

On one of my sites I have a search box with check boxes that alow the user to choose what database they will search.

I use a script to make this possible. In general you configure the script to point to the search script location and change "search=whatever" to make sure you are sending the corrent variable.

The problem is I need to be able to send 5 variables with one search string

for example...
me.com?q=term&a=foo&b=bar&c=www&d=boo

The script I use to redirect will only accept one variable. I have tried various methods but it simply refuses to let me run more than one variable through it. I think the answer may be through htaccess mod_rewrite.

If I was to use the script to set only the first variable to give an output of...
me.com?q=term
then place an entry in htaccess to redirect
me.com?q=term
to
me.com/?q=term&a=foo&b=bar&c=www&d=boo

To an extent this would work using the following

Redirect?q=(.*)
http*/me.com/?q=(.*)&a=foo&b=bar&c=www&d=boo

But will this create a loop because the url it is redirected to follows the same pattern?

This one is realy making my head bust. Beer for the person who solves it. :)

Mack.

1:29 am on Aug 23, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


mack,

Something like this?


RewriteCond %{QUERY_STRING} ^q=([^&]*)$
RewriteRule (.*) /$1?q=%1&a=foo&b=bar&c=www&d=boo [L]

"If the query string consists of "=" and any number of characters NOT to include an ampersand,
then rewrite the URL and first query variable, and add on the other (fixed) query parameters."

Jim

2:03 am on Aug 23, 2003 (gmt 0)

Moderator from GB 

WebmasterWorld Administrator mack is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:June 15, 2001
posts:7833
votes: 90


Thanks jim,
Definatly stops the loop. When I was trying various things out before I seames to either get caught in a loop or loose the query altogether.

It definatly seams to work now. I just need to sort out some syntax at the cgi side of things and i think it will work.

I hate being in a situation where you have more than one variable with more than one script, It's far to easy to loose concentration and get mixed up between the two. lol

Anyway as promised (=) <<beer

Thanks again.

Mack.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members