Forum Moderators: phranque

Message Too Old, No Replies

htaccess redirect to new domain

         

ikeizer

2:27 pm on Apr 16, 2010 (gmt 0)

10+ Year Member



I'm trying to redirect an entire forum subdirectory to a new domain. So /forum should go to newdomain.com/ but /forum/index.php should also be redirected to newdomain.com, as should /forum/viewtopic.php?111 refer to this same base domain.

I can not figure out how to do this correctly. I've checked many threads here, but can't get it to work. Help is appreciated, thanks.

(Please not, using htaccess, modrewrite)

jdMorgan

4:42 pm on Apr 16, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> (Please not, using .htaccess modrewrite)

I'm not sure what that means. Solving this problem may require the use of mod_rewrite, and if you do not have server-config-level privileges, that code will have to go into a .htaccess file.

Please clarify your comment, and post your best-effort code as a basis for discussion.

Thanks,
Jim

ikeizer

4:52 pm on Apr 16, 2010 (gmt 0)

10+ Year Member



Hi Jim, sorry incovenient type. Ofcourse using mod_rewrite and htaccess. Dynamic queries should be stripped from these URLs (old ones consist of phpbb3 urls) and as said simply point to the new root URL. Thanks in advance!

ikeizer

5:26 pm on Apr 16, 2010 (gmt 0)

10+ Year Member



To elaborate, I'm now using

redirectMatch 301 ^(.*)$ http://www.redirectdomain.com

in the htaccess file. Problem is that this results in redirectdomain.com?dynamic_query

[edited by: jdMorgan at 2:11 am (utc) on Apr 17, 2010]
[edit reason] Defeated auto-linking [/edit]

g1smd

7:52 pm on Apr 16, 2010 (gmt 0)

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



Using RewriteRule with [R=301,L] flags will allow you more control over what you want to do.

Redirect and RedirectMatch come from Mod_Alias and are a lot less flexible.

jdMorgan

2:14 am on Apr 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In /forums/.htaccess :

Options +FollowSymLinks -MultiViews
RewriteEngine on
#
RewriteRule ^ http://www.redirectdomain.com/? [R=301,L]

Jim

ikeizer

7:08 am on Apr 17, 2010 (gmt 0)

10+ Year Member



That simple, you should have seen my tries :-)

Thanks a lot, appreciate it.