Forum Moderators: phranque

Message Too Old, No Replies

Redirecting dynamic pages

         

Rob_Dickson

10:58 am on Oct 24, 2009 (gmt 0)

10+ Year Member



I've read quite a few threads on this subject, and can't quite get my redirect to work. I wonder if anybody here can help me.

I'm trying to redirect:
www.example.com/directory/search_results.php?input=n
to:
www.mydomain.com/search_results.php?input=n

The input (n) can be any number.

I tried:
rewritecond %{REQUEST_URI} /directory/search_results.php$
rewritecond %{query_string} ^input=([0-9]+)
RewriteRule ^.*$ http:/www.mydomain.com/search_results.php?input=%1 [R=301,L]

I've only put one / in the RewriteRule so that the forum doesn't convert it to a link.

I'm sure I'm being stupid here, but it redirects to:
www.mydomain.com/search_results.php?q=n

I could always code the PHP to deal with this, but I should be able to get the .htaccess to work.

Thanks in advance.

Rob

Rob_Dickson

11:46 am on Oct 24, 2009 (gmt 0)

10+ Year Member



I've no idea what happened, but I stopped working on my site for lunch, then went back to look at it without making any changes, and everything seems to work OK now.

Sorry for wasting people's time.

Rob

g1smd

1:14 pm on Oct 24, 2009 (gmt 0)

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



Clear browser cache each time!

jdMorgan

2:57 pm on Oct 24, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This rule is over-complicated. The default behavior for RewriteRule is that it leaves query strings unchanged. And RewriteRule can test URL-paths more efficiently than using a RewriteCond. So, you could code this as just a single line:

RewriteRule ^directory/search_results\.php$ http://www.example.com/search_results.php [R=301,L]

Jim