Different Site without the 'WWW'?

General questions relating to Joomla! 1.5 There are other boards for more specific help on Joomla! features and extensions.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Locked
MatthewSchenker
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 233
Joined: Tue Nov 25, 2008 7:10 pm

Different Site without the 'WWW'?

Post by MatthewSchenker » Thu Jun 04, 2009 10:56 am

Hello,
I'm having a weird issue with my site.

If someone enters 'http://www.dwaa.org' as the address, everything works fine.

But if someone enters just 'http://dwaa.org' certain graphics produce errors.

I've built a few sites before and it never seemed to matter. Can someone tell me what settings or files I need to change to fix this?

Thanks,
Matt

 
Rochen-Adam
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 135
Joined: Thu May 28, 2009 6:05 pm
Location: California, USA
Contact:

Re: Different Site without the 'WWW'?

Post by Rochen-Adam » Thu Jun 04, 2009 11:11 am

Hi Matt,

I'm not seeing any errors from here, the site looks great when accessed via either URL. This sounds like a DNS or caching issue on your end. Can you clear your browser cache, flush your DNS cache (or restart your computer) and reboot your modem/router if you have one?
http://www.rochen.com - Performance Joomla Hosting Solutions - Make your Joomla! install fly.
http://blog.rochen.com - Great security tips and more for Joomla!
Follow us on Twitter @rochenhost

User avatar
dhuelsmann
Joomla! Master
Joomla! Master
Posts: 19658
Joined: Sun Oct 02, 2005 12:50 am
Location: Omaha, NE
Contact:

Re: Different Site without the 'WWW'?

Post by dhuelsmann » Thu Jun 04, 2009 1:09 pm

You can force your users to a particular site prefix by using this in .htaccess:
Try this code in your .htaccess changing it to fit your situation

Code: Select all

########## Begin - Redirecting non-www request to www
#
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule (.*) http://www.mysite.com/$1 [L,R=301]
#
########## End - Redirecting non-www request to www
Regards, Dave
Past Treasurer Open Source Matters, Inc.
Past Global Moderator
http://www.kiwaniswest.org

MatthewSchenker
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 233
Joined: Tue Nov 25, 2008 7:10 pm

Re: Different Site without the 'WWW'?

Post by MatthewSchenker » Thu Jun 04, 2009 1:28 pm

dhuelsmann,
Thanks for the tip! I made the changes to my .htaccess file, but the errors are still showing up.

Maybe I did not code it correctly? Did I perhaps put something in literally that needs to be specific to my account?

Here's the exact code I entered:

Code: Select all

########## Begin - Redirecting non-www request to www
#
RewriteEngine On
RewriteCond %{HTTP_HOST} ^dwaa.org [NC]
RewriteRule (.*) http://www.dwaa.org/$1 [L,R=301]
#
########## End - Redirecting non-www request to www
Thanks again,
Matt

User avatar
dhuelsmann
Joomla! Master
Joomla! Master
Posts: 19658
Joined: Sun Oct 02, 2005 12:50 am
Location: Omaha, NE
Contact:

Re: Different Site without the 'WWW'?

Post by dhuelsmann » Thu Jun 04, 2009 5:14 pm

First - did you put it immediately after the RewriteEngine On that should already be in your .htaccess (You don't need two of these statements)? If you didn't and you are using the Joomla provided .htaccess then the other statements preceeding it will cause it to fail.
Regards, Dave
Past Treasurer Open Source Matters, Inc.
Past Global Moderator
http://www.kiwaniswest.org

MatthewSchenker
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 233
Joined: Tue Nov 25, 2008 7:10 pm

Re: Different Site without the 'WWW'?

Post by MatthewSchenker » Thu Jun 04, 2009 5:39 pm

dhuelsmann wrote:First - did you put it immediately after the RewriteEngine On that should already be in your .htaccess (You don't need two of these statements)? If you didn't and you are using the Joomla provided .htaccess then the other statements preceeding it will cause it to fail.
OK, yes, I put it at the end of the .htaccess file.

So do I get rid of the RewriteEngine section and replace it with this new one? Or do I add the code you gave me to the existing RewriteEngine section?

Thank you very much for your help. I really appreciate it.

Matt

User avatar
dhuelsmann
Joomla! Master
Joomla! Master
Posts: 19658
Joined: Sun Oct 02, 2005 12:50 am
Location: Omaha, NE
Contact:

Re: Different Site without the 'WWW'?

Post by dhuelsmann » Thu Jun 04, 2009 6:01 pm

Place this

Code: Select all

RewriteCond %{HTTP_HOST} ^dwaa.org [NC]
RewriteRule (.*) http://www.dwaa.org/$1 [L,R=301]
right after this

Code: Select all

RewriteEngine On
Regards, Dave
Past Treasurer Open Source Matters, Inc.
Past Global Moderator
http://www.kiwaniswest.org

MatthewSchenker
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 233
Joined: Tue Nov 25, 2008 7:10 pm

Re: Different Site without the 'WWW'?

Post by MatthewSchenker » Thu Jun 04, 2009 6:12 pm

dhuelsmann,
Excellent -- that did it. Now when I enter http://dwaa.org, the site automatically redirects me to http://www.dwaa.org.

I hope this helps other people needing to do the same thing.

Thanks for patiently guiding me through this.

Matt

Drathnar
Joomla! Apprentice
Joomla! Apprentice
Posts: 7
Joined: Mon Sep 22, 2008 4:48 pm

Re: Different Site without the 'WWW'?

Post by Drathnar » Wed Jun 24, 2009 4:48 pm

I am having this issue as well (and yes I am using my url instead of mysitehere :)


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

#
# mod_rewrite in use

RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysitehere.com [NC]
RewriteRule (.*) http://www.mysitehere.com/$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!
#
# 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 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

User avatar
dhuelsmann
Joomla! Master
Joomla! Master
Posts: 19658
Joined: Sun Oct 02, 2005 12:50 am
Location: Omaha, NE
Contact:

Re: Different Site without the 'WWW'?

Post by dhuelsmann » Wed Jun 24, 2009 6:42 pm

@Drathner

Why don't you check and make sure that rewrite is working on your server.
Let's test to see if mod_rewrite is enabled on your server. Place only the following code in .htaccess:

Code: Select all

RewriteEngine On
Options +FollowSymLinks
Redirect /google.html http://www.google.com
Now point your browser to: http://www.yoursite.com/google.html
If it redirects you to Google - mod_rewrite is working.
If it gives you an error - mod_rewrite is not working.

Note: Replace "www.yoursite.com" with your actual web site domain.
Regards, Dave
Past Treasurer Open Source Matters, Inc.
Past Global Moderator
http://www.kiwaniswest.org

Drathnar
Joomla! Apprentice
Joomla! Apprentice
Posts: 7
Joined: Mon Sep 22, 2008 4:48 pm

Re: Different Site without the 'WWW'?

Post by Drathnar » Wed Jun 24, 2009 7:04 pm

Ok i feel stupid i figured out what my issue was I had two copies of htaccess on my server one being a backup and I was editing the wrong one.. ugh lol it's working now thanks for your help/time though :)

DNic41
Joomla! Apprentice
Joomla! Apprentice
Posts: 15
Joined: Sun Aug 30, 2009 9:39 pm

Re: Different Site without the 'WWW'?

Post by DNic41 » Thu Sep 17, 2009 3:54 am

Ah was having the same issue with some pages not coming up with www and some with. Thanks for the info, worked perfectly!

User avatar
Yxos
Joomla! Intern
Joomla! Intern
Posts: 75
Joined: Fri Jul 24, 2009 3:09 am
Location: Denmark
Contact:

Re: Different Site without the 'WWW'?

Post by Yxos » Sun Oct 18, 2009 6:54 am

I have the opposite request: I want the site WITHOUT www, even the user enters www in the URL.

Using the .htaccess provided in 5.1.14 I added a few lines to accomplish this.
Note, that the domain name is not a part of of the RewriteCond or RewriteRule. It can be used as-is on any site:

Code: Select all

##
# @version $Id: htaccess.txt 10492 2008-07-02 06:38:28Z ircmaxell $
# @package Joomla
# @copyright Copyright (C) 2005 - 2008 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 rule to enforce NOT to use prefix www.
#
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
#
########## End - Rewrite rule to enforce NOT to use prefix www.

########## 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!
#
# 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 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
/Yxos

 

Locked

Return to “General Questions/New to Joomla! 1.5”