Sign Up for OSTraining

Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Question re Redirect WWW to non-WWW domain

Question re Redirect WWW to non-WWW domain 1 year 1 week ago #45790

  • hankedson
  • hankedson's Avatar
  • OFFLINE
  • OSTar
  • Posts: 136
  • Karma: 0
Hello,

Below is the code from my .htaccess file including the part where I added two lines per the instructions in Session 3 of the SEO course for redirecting www to non-www domain. The code added, as you can see down below is: "RewriteCond %{HTTP_HOST} ^www.familytreemediation.net [NC] RewriteRule ^(.*)$ familytreemediation.net/$1 [L,R=301]" I have uploaded the file to my host and cleared my caches and yet on Chrome at least I still see two different domains: www.familytreemediation.net and familytreemediation.net. I note that there are a lot of #'s in this file and I don't know what they mean syntactically. Perhaps that is my problem. Can anyone tell me what change to make to get this to work properly?

Thank you,

Hank
##
# @version $Id: htaccess.txt 14401 2010-01-26 14:10:00Z louis $
# @package Joomla
# @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
# @license 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
RewriteCond %{HTTP_HOST} ^www.familytreemediation.net [NC] RewriteRule ^(.*)$ familytreemediation.net/$1 [L,R=301]
########## 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
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%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})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits

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

# RewriteBase /


########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section
Hank
Please become a member of OSTraining to reply to this post.

Question re Redirect WWW to non-WWW domain 1 year 1 week ago #45794

  • edandrea
  • edandrea's Avatar
  • OFFLINE
  • OSTop Dog
  • Posts: 3106
  • Thank you received: 7
  • Karma: 0
Hi Hank,

To see if it makes a difference try it this way.Redirect non-www to www

RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ www.yourdomain.com/$1 [L,R=301]

RewriteCond %{HTTP_HOST} ^familytreemediation.net [NC] RewriteRule ^(.*)$ www.familytreemediation.net/$1 [L,R=301]

Also this can be done at the server level and you can avoid htaccess altogether. If you don't see an option for it in your control panel ask tech support how to do it or do it for you. It will depend on who your host is. I use Hostgator and I don't have to deal with this.

Let us know.
Cheers,
Ed
Please become a member of OSTraining to reply to this post.

Question re Redirect WWW to non-WWW domain 1 year 1 week ago #45802

  • hankedson
  • hankedson's Avatar
  • OFFLINE
  • OSTar
  • Posts: 136
  • Karma: 0
Hi Ed,

Thank you for your help. Unfortunately, it doesn't seem to work either way.

Hank
Hank
Please become a member of OSTraining to reply to this post.

Question re Redirect WWW to non-WWW domain 1 year 1 week ago #45806

  • edandrea
  • edandrea's Avatar
  • OFFLINE
  • OSTop Dog
  • Posts: 3106
  • Thank you received: 7
  • Karma: 0
The # marks mean the line is commented out or turned off. A line with no hash mark is active and turned on. You could try removing the # from #Rewrite Base /

If that doesn't work, try replacing the file with a generic one and try it again to make sure. Perhaps you have a stray character or space or something that is preventing it from working.

You could use this generator to help avoid typing errors for the code you insert.
www.scriptalicious.com/tools/www-redirect-generator/

Try activating Rewrite Base, and let me know.

Ed
Please become a member of OSTraining to reply to this post.

Question re Redirect WWW to non-WWW domain 1 year 1 week ago #45912

  • hankedson
  • hankedson's Avatar
  • OFFLINE
  • OSTar
  • Posts: 136
  • Karma: 0
Hi Ed,

I got it working! I'm not sure what did it. I did copy the code from the tutorial and put my domain in but it looked exactly the same as what was in there (which I did not remove until I compared the two.) Then it didn't work so I removed a # from the wrong area and crashed my site. So I put the # back in and when my site was up again, the redirect was working. So thank you for helping and for encouraging me to double check and not give up.

Best,

Hank
Hank
Please become a member of OSTraining to reply to this post.

Question re Redirect WWW to non-WWW domain 1 year 1 week ago #45914

  • edandrea
  • edandrea's Avatar
  • OFFLINE
  • OSTop Dog
  • Posts: 3106
  • Thank you received: 7
  • Karma: 0
Hi Hank,

Sometimes I think Joomla is scared into submission by persistence. Nice job.

Cheers,
ed
Please become a member of OSTraining to reply to this post.
  • Page:
  • 1

Sign Up for OSTraining

Open Source Training is not affiliated with or endorsed by the Joomla, WordPress or Drupal projects.
All product names and trademarks are the property of their respective owners.

Copyright 2013 Open Source Training, LLC. All rights reserved.