Forum Moderators: phranque

Message Too Old, No Replies

301 redirect from root to subfolder keeping file names?

         

Caesar

7:34 am on May 30, 2009 (gmt 0)

10+ Year Member



Here is what I have done. Ive moved what was in my root (my forum) into a subfolder called forum as Im doing other things in the top level directory now.

I would like to 301 redirect all incoming traffic to the old forum to the new structure.

For example it would be:

[domain.com...] -> [domain.com...]

[domain.com...] -> [domain.com...]

The blah and meh are subforum names made to look like directories using vbSEO.

Basically I just need /forum/ stuck in between the links. I do not mind having to go through and manually add all the subforums such as meh and blah (theres about 20 of them), because not doing so I assume would ruin future directories (say I add /blog/ I dont want it automatically redirect to /forum/blog/). But the thread, and showforum, and memberprofile, post, etc files would need to be wildcarded.

Hoping someone here can help me.

g1smd

10:16 am on May 30, 2009 (gmt 0)

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



We had a long thread on this exact topic (except it was /blog/ rather than /forum/ I believe) just a week or so back.

The point I made there (repeatedly, and which was completely overlooked), was that just because you have moved files around on the server, you don't have to change the URLs that users see and use.

Changing URLs can lead to ranking and traffic losses.

Would you like to keep the same URLs for your users?


If you insist on forcing search engines and your users to see new URLs, then you need a 301 redirect for that; examples of which are posted several times per day in this forum.

We can advise you on your code; there's not enough volunteers to provide a free code-writing service here.

jdMorgan

12:28 pm on May 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



example.com/blah/thread223424.php -> example.com/forum/blah/thread223424.php
example.com/meh/post1234.php -> example.com/forum/meh/post1234.php

 RewriteRule ^((blah¦meh¦foo)/.*)$ http://example.com/forum/$1 [R=301,L]

This assumes that you've got other working mod_rewrite rules, and that the required setup directives for mod_rewrite are already present.

Replace the broken pipe "¦" characters with solid pipe characters before use; Posting on this forum modifies the pipe characters.

Jim