XF 1.3 Switching domain, keeping old one, redirects

Floyd R Turbo

Well-known member
I wish to change my xenforo domain from olddomain.com to newdomain.com, and then use olddomain.com for another purpose.

I was told by my host that the first part is simple, but the second part might be difficult because the redirect script would prevent traffic from getting to olddomain.com. It will probably be a month or two before I would want to start using olddomain.com for anything (product sales site).

So would this be possible with a well-written redirect script?
 
@Jake Bunce you seem to be the only one willing to help me answer these questions. Anyone else please feel free to chime in, I didn't think this was a complicated question, I honestly expected that it would be easy to answer. I wanted to do this conversion last week Tuesday.

My only question at this point is regarding the need for the 3rd .htaccess file and what it should look like (i.e. do I have it right or not). That's all I'm waiting on.

Someone please help!!!!!
 
Now that I look at this again after learning a bit I wonder if the .htaccess file in the olddomain root isn't quite right.

I had it as this:

Code:
ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 500 default

<IfModule mod_rewrite.c>
RewriteEngine On

#redirect all but root and index to newdomain
RewriteRule ^$ - [S=2]
RewriteRule ^index\.php$ - [S=1]
RewriteRule ^(.*)$ https://www.newdomain.com/$1 [R=301,L]
#note: I changed the above line to https and I run SSL

#redirect http to https
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.newdomain.com/$1 [R,L]

#make exception for XF's thread URL format
RewriteRule ^threads/[^\.]+\.[0-9]+/ - [S=1]
#redirect vB's thread URL format
RewriteRule ^threads/([0-9]+)-.*$ /threads/$1? [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</IfModule>

But something doesn't make sense. All that is going to be in the olddomain, at first, is an index.html file (eventually, a Magento cart) but doesn't that mean that

RewriteRule ^index\.php$ - [S=1]

should be

RewriteRule ^index\.html$ - [S=1]?

Then, if the point is to not redirect the root and index.html hits to the new domain, the first 2 rules would take care of these conditions and skip the third line. From that point on, the next line would, as written, redirect http://www.olddomain.com to https://www.newdomain.com, would it not? So I don't want that, I want olddomain there (and I will have SSL on the old domain, so I would want to redirect http to https)

So if I follow the logic here, the only hits that will not be redirected will be root and index.html, and if the hit was to http it would be redirected to https. Everything else would go to the new domain. There are no other possibilities, so I shouldn't need the rest of the file, should I? This means that the olddomain .htaccess file would just be:

Code:
ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 500 default

<IfModule mod_rewrite.c>
RewriteEngine On

#redirect all but root and index to newdomain
RewriteRule ^$ - [S=2]
RewriteRule ^index\.html$ - [S=1]
RewriteRule ^(.*)$ https://www.newdomain.com/$1 [R=301,L]

#redirect http to https
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.olddomain.com/$1 [R,L]

</IfModule>

Correct?

And then of course I have thought of one other potential issue, related to SSL on the new domain. Will is cause any issues to have https in the 3rd rule instead of http like you first recommended? If my .htaccess file in the root of the new domain has the http->https rewrite rule, will that take care of it, or can I leave the olddomain .htaccess file as I show it?
 
Last edited:
Top Bottom