Forum Moderators: phranque

Message Too Old, No Replies

Redirect old domain name and accidentally cache IP address

Need to know the best SEF method for handling my situation

         

cledo

8:47 pm on Nov 15, 2011 (gmt 0)

10+ Year Member


Okay, I'm going to try to explain this the best I can. I apologize right off the bat...

I've recently developed a new joomla site that isn't live yet. Before I go live with it, I need to address the existing links Google has cached for two domains since a few of them for each domain have page 1 listings and I hope to carry over their rankings.

Here is my current scenario: The primary domain (let's call it www.domain1.com) points to the current site. There is another domain that has a cname record which points to the primary domain and we'll call that www.domain2.com. Google has, of course, indexed various links under both domain names.

This is what I "hope" to do without disturbing the search engine ranking. There will only be one domain, and that will be www.domain2.com. I hope to 301 redirect all of the existing www.domain1.com links AND www.domain2.com/subfolder links (that don't match the sef urls of the new site) to the appropriate page(s) on the new www.domain2.com site. There is also another dilemma I hope to resolve. Google has indexed 150 links of my temporarily hosted IP address (along with folders that should NEVER be indexed like "components"[smilestopper]) against the wishes of my robots.txt file. I was able to find the necessary rewriterule for that but would like to get all of your professional opinions as to the accuracy/security.

Here is what I have:

##
# @version $Id: htaccess.txt 21064 2011-04-03 22:12:19Z dextercowley $
# @package Joomla
# @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
# @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
# Joomla! is Free Software
##


#####################################################
# READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE
#
# The line just below this section: 'Options +FollowSymLinks' may cause problems
# with some server configurations. It is required for use of mod_rewrite, but may already
# be set by your server administrator in a way that dissallows changing it in
# your .htaccess file. If using it causes your server to error out, comment it out (add # to
# beginning of line), reload your site in your browser and test your sef url's. If they work,
# it has been set by your server administrator and you do not need it set here.
#
#####################################################

## Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

#
# mod_rewrite in use

RewriteEngine On

########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
## Deny access to extension xml files (uncomment out to activate)
#<Files ~ "\.xml$">
#Order allow,deny
#Deny from all
#Satisfy all
#</Files>
## End of deny access to extension xml files
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode data within the URL
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
#
########## End - Rewrite rules to block out some common exploits


########## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.




RewriteCond %{HTTP_HOST} ^123\.456\.789\.012 [OR]
RewriteCond %{HTTP_HOST} ^domain1\.com [OR]
RewriteCond %{HTTP_HOST} ^domain2\.com
RewriteRule (.*) http://www.domain2.com/$1 [R=301,L]



redirectMatch 301 /pet-boarding-reservation http://www.domain2.com/ann-arbor-dog-boarding-toledo-ohio
redirectMatch 301 /employment http://www.domain2.com/
redirectMatch 301 /reservations http://www.domain2.com/ann-arbor-dog-boarding-toledo-ohio
redirectMatch 301 /contact http://www.domain2.com/contact-karnik-pet-lodges-karnik-memorial-garden
redirectMatch 301 /locations http://www.domain2.com/contact-karnik-pet-lodges-karnik-memorial-garden
redirectMatch 301 /faq.html http://www.domain2.com/dog-boarding-dog-daycare-faqs
redirectMatch 301 /article.html http://www.domain2.com/
redirectMatch 301 /about.html http://www.domain2.com/about-us
redirectMatch 301 /links.html http://www.domain2.com/
redirectMatch 301 /pet-cams http://www.domain2.com/ann-arbor-michigan-pet-cams
redirectMatch 301 /locations/ann-arbor http://www.domain2.com/dog-boarding-ann-arbor-michigan
redirectMatch 301 /locations/maumee-monclova http://www.domain2.com/dog-boarding-maumee-monclova-ohio
redirectMatch 301 /services/dog-boarding http://www.domain2.com/ann-arbor-dog-boarding-toledo-ohio
redirectMatch 301 /services/doggie-daycare http://www.domain2.com/ann-arbor-dog-daycare-toledo-ohio
redirectMatch 301 /toledo-sylvania http://www.domain2.com/dog-boarding-toledo-ohio
redirectMatch 301 /services/cat-boarding http://www.domain2.com/cat-boarding-ann-arbor-toledo-ohio
redirectMatch 301 /services/dog-grooming http://www.domain2.com/dog-bathing-monclova-toledo-ohio
redirectMatch 301 /locations/photo-tour.html http://www.domain2.com/contact-karnik-pet-lodges-karnik-memorial-garden
redirectMatch 301 /forms/karnik-dcc-enrollment.pdf http://www.domain2.com/doggie-daycare-enrollment-form
redirectMatch 301 /locations/maumee-monclova/map-fallen-timbers.pdf http://www.domain2.com/karnik-in-maumee-monclova-ohio-map
redirectMatch 301 /locations/ann-arbor/map-maple-village.pdf http://www.domain2.com/karnik-in-ann-arbor-michigan-map
redirectMatch 301 /locations/toledo-sylvania/map-central-avenue.pdf http://www.domain2.com/karnik-in-toledo-ohio-map



########## End - Custom redirects


# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root)

RewriteBase /~karnik


########## Begin - Joomla! core SEF Section
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the request is for root, or for an extensionless URL, or the
# requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} (/[^.]*|\.(php|html?|feed|pdf|raw))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
#
########## End - Joomla! core SEF Section


Also, www.domain1.com points to a server I don't have access to (fun, I know). I DO have control of both domains.[b] Will I be able to use the above code after I update the nameservers of www.domain1.com to the same nameservers as www.domain2.com (when I go live) to control the redirects for www.domain1.com[/b] since I can't place an .htaccess file on the server? I eventually want to abandon www.domain1.com altogether, but only after all backlinks have disappeared.

You'll also notice I'm using redirects within the .htaccess file for all of the old indexed links so they redirect to www.domain2.com's respective pages.

I'm really sorry for all of this guys and I REALLY appreciate your expert advice. I just can't afford to mess this up.

g1smd

10:36 pm on Nov 15, 2011 (gmt 0)

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



Change all the RedirectMatch code to use RewriteRule code.

List all of those rules before your domain canonicalisation rule.

This avoids a double redirect for some non-canonical requests.


I wrote the note

# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.


so that people would hopefully get those hints upfront.

cledo

2:07 pm on Nov 16, 2011 (gmt 0)

10+ Year Member


Thank you g1smd. Sorry I didn't catch that note. I just see everyone on the internet using the Redirect 301. Having minimal knowledge of mod_Rewrite, can you tell me if this would be the correct syntax for each RewriteRule:

RewriteRule ^/pet-boarding-reservation$ http://www.domain2.com/ann-arbor-dog-boarding-toledo-ohio [R=301,NC]

These aren't directories, but rather files without extensions.

Also, if I point www.domain1.com at this new site (pointed at somebody else's server right now), will it automatically rewrite the urls for indexed links such as http://www.domain1.com/pet-boarding-reservation?

Again, thank you very much.

cledo

2:09 pm on Nov 16, 2011 (gmt 0)

10+ Year Member



Sorry, that was supposed to have the [R=301,L,NC] flags.

g1smd

7:40 pm on Nov 16, 2011 (gmt 0)

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



You might not need the NC flag.

After the caret the first slash should be removed.

The redirect will work for any and all domains that point at the folder where the htaccess file resides.