Forum Moderators: phranque

Message Too Old, No Replies

Moved /folder/ to subdomain . how to redirect all?

         

AngelsAdvocate

5:24 pm on May 17, 2006 (gmt 0)

10+ Year Member



I had a forum in the folder /phpbb2/
I have just created a subdomain of forum.domain.com

How can I set up a rewrite to direct all the /phpbb2/viewtopic.php type links to forum.domain.com/viewtopic.php?

Thanks for any help

AngelsAdvocate

9:06 pm on May 17, 2006 (gmt 0)

10+ Year Member



Anyone able to help?

AngelsAdvocate

9:43 pm on May 17, 2006 (gmt 0)

10+ Year Member



Seems I managed to do it with:

redirect 301 /phpbb2/ [forum.domain.com...]

I guess this is all I need to do and it should work well, have tested and seems ok. Now hoping Google won't punish me for it.

jdMorgan

2:51 am on May 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A 301 is the correct solution, and Google should not punish you for it. Google typically doesn't punish anyone who doesn't cheat or publish junk and try to claim it as useful content. They occasionally do make mistakes, but punishment is generally reserved for the deserving. If old, truly-useful sites start to disappear from search results, you can be pretty sure that there's just a temporary Googlebug in effect. In the recent "Big Daddy" update, my highest-quality sites are untouched and some even doing better, while my lower-quality sites either moved up slightly, stayed the same, or moved down just slightly. I don't have any "junk sites," and so can't comment on what happened to those, although there is plenty of discussion elsewhere on the subject.

Glad you found an answer and tested succesfully.

Jim

RossS

5:01 am on Jun 3, 2006 (gmt 0)

10+ Year Member



I am trying to do this same thing, using the code below.

RewriteEngine On
#
#RewriteCond %{HTTP_HOST}!^sub\.
#RewriteRule ^(.*)$ [sub.domain.tld...] [L,R=301]

however it is rewriting the url with the derectory structure.

ie:
[sub.domain.tld...]

what am I doing wrong?

Thanks in advance
Ross

jdMorgan

1:39 am on Jun 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The back-reference will copy the entire URL-path, as requested. If you need to remove 'sub' from the requested URL, then you'll need to do so explicitly by matching it outside of the back-reference... Something like:

RewriteCond %{HTTP_HOST} !^sub\.
RewriteRule ^(.*)[b]/sub/?[/b]$ http://sub.domain.tld/$1 [L,R=301]

Jim

RossS

3:11 am on Jun 4, 2006 (gmt 0)

10+ Year Member



Thanks for trying to help, but unfortunately that did not work.

I changed it to this

RewriteCond %{HTTP_HOST} !^sub\.
RewriteRule ^(.*)/?$ http://sub.domain.tld/$1 [L,R=301]

and it works, to redirect/rewrite the url to sub.domain.tld. However it messes up the furls, which after this adjustment return a 500 Internal Server Error

here's all of my file

RewriteEngine On
RewriteCond %{HTTP_HOST} !^sfl\.
RewriteRule ^(.*)/?$ http://sfl.example.com/$1 [L,R=301]
#
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

when #RewriteBase / is uncommented the site works if accessed by sub.domain.tld but if accessed by domain.tld/sub it again shows the directory structure :S

[edit]
I kept trying, even though I still don't really understand this, and was able to get it working. The end result is this

RewriteEngine On
#
RewriteCond %{HTTP_HOST} !^sfl\.
RewriteRule ^(.*)?$ http://sfl.example.com/$1 [L,R=301]
#
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

[end edit]

[edited by: jdMorgan at 2:21 pm (utc) on June 4, 2006]
[edit reason] No URLs, please. See TOS. [/edit]

RossS

11:04 am on Jun 6, 2006 (gmt 0)

10+ Year Member



sorry about that, must have forgot to edit that.

by the way the above only works as intended if the / is pressent at the end of the dir name.

RewriteRule ^/*(.+/)?([^.]*[^/])$ [%{HTTP_HOST}...] [L,R=301]

is that the best way to fix the missing back slash?