Forum Moderators: phranque

Message Too Old, No Replies

Redirect root folders to a subdomain

moved old html files to a subdomain

         

digic

4:22 pm on Jul 21, 2011 (gmt 0)

10+ Year Member



Hi,

I wanted to implement the right code when redirecting a folder to a subdomain. I have an old folder /public_html/folder1 that I moved to a new subdomain "old.domain.com/folder1/". Im I using the right code?

Options +FollowSymLinks -MultiViews
RewriteEngine on
#
Redirect 301 /folder1/ http: //old.domain.com/folder1/

g1smd

4:40 pm on Jul 21, 2011 (gmt 0)

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



I would use

RewriteRule ^([^/]+/)*index\.(html?|php)$ http://old.example.com/folder/$1 [R=301,L]
RewriteRule (.*) http://old.example.com/folder/$1 [R=301,L]


as I never mix RewriteRule (mod_rewrite) with directives using mod_alias (Redirect/RedirectMatch) in the same site.

I use two lines of code so that index requests do not invoke an unwanted redirection chain.

This avoids all kinds of difficult-to-diagnose problems.

digic

4:57 pm on Jul 21, 2011 (gmt 0)

10+ Year Member



Thanks g1smd. My code is showing "too many redirect errors" in Chrome. In IE, it takes time for the page to load.

Actually, the old design have dozens of .htm files and folders (with .htm files also) which I want to move to a subdomain. Right now, I am using wordpress to run the site. Still I dont want to delete old .htm files since they are still useful.

Should I write one rewrite rule for each folder? What about all the .htm files that was moved to a subdomain?

Im sorry, I am confuse with these codes.

digic

5:13 pm on Jul 21, 2011 (gmt 0)

10+ Year Member



To give you a better view, here is how the old design looks. All in .htm file.
/public_html/
index.htm
aaa.htm
bbb.htm
ccc.htm
/folder1/ddd.htm (and so on)
/folder2/eee.htm (and so on)

So I created a subdomain "old" to move all old files like this:
/public_html/old/
index.htm
aaa.htm
bbb.htm
ccc.htm
/folder1/ddd.htm (and so on)
/folder2/eee.htm (and so on)

Under /public_html/ or root, there are Wordpress files and folders which I dont want to get affected. Thanks

lucy24

7:15 pm on Jul 21, 2011 (gmt 0)

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



Wait, wait. Is it
old.domain.com/
or is it
domain.com/old/
or is it both [httpd.apache.org]? That is, what the user sees and the real location of the file may or may not be the same.

digic

5:48 am on Jul 22, 2011 (gmt 0)

10+ Year Member



The newly created subdomain is old.domain.com and if your browsing the folders via FTP it is under /public_html/old/(all files and folders must go here).

So if visitors browse /public_html/old/folder1/ddd.htm he would get a URL [old.domain.com...]