Forum Moderators: phranque
You kindly helped be a couple of time before with code below:
########## Begin - Rewrite rules to enhance SEO SEF
#
# Externally redirect to canonical hostname, preserving the original
# request's http/https protocol, but excluding xmlrpc requests.
RewriteCond $1 !xmlrpc [NC]
RewriteCond %{HTTP_HOST} ^(originaldomain\.org|www\.originaldomain\.org(\.|\.?[0-9]+)$) [NC]
RewriteCond %{SERVER_PORT}>s ^(443>(s)|80>s)$
RewriteRule ^(.*)$ http%2://www.originaldomain.org/$1 [R=301,L]
#
########## End - Rewrite rules to enhance SEO SEF The website is now changing names and has a new domain name pointing to the same site.
How do I update the code to point all requests for originaldomain to newdomain keeping the www rewrite intact?
Thanks in advance.
I don't really know what I'm doing... I tried something yesterday which didn't work, tried this today and it seems to be working! ;)
########## Begin - Rewrite rules to enhance SEO SEF
#
# Externally redirect to canonical hostname, preserving the original
# request's http/https protocol, but excluding xmlrpc requests.
RewriteCond $1 !xmlrpc [NC]
RewriteCond %{HTTP_HOST} ^(origdomain\.org|www\.origdomain\.org|newdomain\.org|www\.newdomain\.org(\.|\.?[0-9]+)$) [NC]
RewriteCond %{SERVER_PORT}>s ^(443>(s)|80>s)$
RewriteRule ^(.*)$ http%2://www.newdomain.org/$1 [R=301,L]
#
########## End - Rewrite rules to enhance SEO SEF Is this correct? can I optimise?
DM.
That code looks basically OK, but you can shorten it up a bit -- specifically the "origdomain" and "www.origdomain" subpattern in the second RewriteCond:
# Redirect requests for all "origdomain.org" variants, non-www "newdomain.org"
# variants, and any www.newdomain.org variants which have a FQDN indicator and/or
# an appended port number to "www.newdomain.org".
RewriteCond %{HTTP_HOST} ^((www\.)?origdomain\.org|newdomain\.org|www\.newdomain\.org(\.|\.?[0-9]+)$) [NC,OR]
But let me ask this: This rule will not redirect xmlrpc requests for *either* domain. Is that what you want?
Jim