Forum Moderators: phranque

Message Too Old, No Replies

Htaccess : Redirect a dynamic url to another dynamic url

         

casafree

10:47 pm on Oct 9, 2008 (gmt 0)

10+ Year Member



Hello.
I have a discussion board, and would like to redirect some page using htaccess :
For example, i need to redirect this page :

viewforum.php?id=470&fid=7
to
viewforum.php?id=470&fid=11

(i Want to redirect only forums with id 470)

Anybody can help me with that ?

g1smd

11:21 pm on Oct 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes, example code is all over this forum.

You'll need to test %{QUERY_STRING} as well as having your RewriteRule.

The RewriteRule needs to also force www at the same time as changing the query string.

Make sure it returns a 301 redirect.

Post your best effort code here as a basis for discussion.

casafree

3:17 pm on Oct 17, 2008 (gmt 0)

10+ Year Member



Hello, Thank you for your reply.
I dont know how to use Query_String
This is what i have tried, but it (of corse) didn't work :

Redirect 301 viewforum.php?id=470&fid=7 /viewforum.php?id=470&fid=11

I also tried :
Redirect 301 viewforum.php?id=470&fid=7 h**p://***.domainame.com/viewforum.php?id=470&fid=11

How can we use Query_string for a 301 redirect ?

casafree

4:08 pm on Oct 17, 2008 (gmt 0)

10+ Year Member



Ok, worked !
Thank you g1smd for the query_string tip.

Her is my htaccess file if somebody need it :

RewriteEngine On
RewriteCond %{QUERY_STRING} var1=28689&var2=14
RewriteRule viewtopic.php hxxp://www.domain.com/forum/viewtopic.php?var1=28689&var2=68 [R=301,L]

g1smd

5:35 pm on Oct 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That should work, but what happens if someone requests the URL with the two parameters in this order:

var2=14&var1=28689

or with another parameter between these two?