Forum Moderators: phranque

Message Too Old, No Replies

Rewrite directory to a single webpage -Need help

         

jpietrowiak

10:06 pm on Mar 20, 2009 (gmt 0)

10+ Year Member



I moved a forum from site.com/forum/ to sub.site.com. I am using a whole different forum software. How do I write a redirect to take any requests from search engines to old pages and bring them to my home page of sub.site.com without having the rest of the transfered link added to it for example sub.site.com/?=id7777 . It appears everything I do adds on the end of the old forum url to the new one.

jpietrowiak

10:53 pm on Mar 20, 2009 (gmt 0)

10+ Year Member



It appears that that for example the viewtopic.php?pid=7777 will drop the viewtopic.php but stops at the ? mark.

here is what I had in htaccess both of these things by themselves had the same results.

redirectMatch 301 ^/forum/ [sub.site.com...]
or
ReWriteRule ^forum.*$ [sub.site.com...] [L,R=301]

g1smd

11:01 pm on Mar 20, 2009 (gmt 0)

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



RewriteRule cannot directly see query strings. Add a RewriteCond that looks at QUERY_STRING here.

Ah, you want to know how to drop the query string... add a question mark after the target URL of the RewriteRule to drop it.

jpietrowiak

11:11 pm on Mar 20, 2009 (gmt 0)

10+ Year Member



Can you give a example. I'm not much of a coder.
I tried
redirectMatch 301 ^/forum/ [cncforums.site.com?...]

and it worked sort of going to exactly [cncforums.site.com?...] but the questionmark was in it.

I did try below and it worked however is this the same as a 301 redirect for Search engines as well for permanent moved.
ReWriteRule ^forum.*$ [cncforums.site.com?...] [L,R=301]

Thanks

g1smd

11:51 pm on Mar 20, 2009 (gmt 0)

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



Both pieces of code return a 301 to all users.

RewriteRule is the more versatile/powerful way to do this, so use that one.

[b]R[/b]ewrite[b]R[/b]ule ^foru[b]m h[/b]ttp://cncforums.site.co[b]m/?[/b] [R=301,L]

Note the minor corrections to style.

jpietrowiak

12:15 am on Mar 21, 2009 (gmt 0)

10+ Year Member



Worked great! thanks for the help g1smd