0
Welcome Guest! Login
0 items Join Now

SOLVED Force users to use http://www.yoursite.com problems?

    • oj09's Avatar
    • oj09
    • Hero Rocketeer
    • Posts: 395
    • Thanks: 0

    SOLVED Force users to use http://www.yoursite.com problems?

    Posted 11 years 10 months ago
    • Hi All,

      My site is using the non www method at present and for the purposes of an SSL cert that's to be implemented soon etc, I need to get my site away from swswsws.co.uk to www.swswsws.co.uk .

      So, I've been using the following article to help me set this up: http://www.htaccessbasics.com/force-www-nonwww-domain/

      So I've done as directed and added the following to my .htaccess file;
       
      # Redirect non-www urls to www
      RewriteEngine on
      RewriteCond %{HTTP_HOST} ^swswsws\.co.uk [NC]
      RewriteRule (.*) http://www.swswsws.co.uk/$1 [R=301,L]

      However, it's just giving a flat out I don't want to load for you pain in the ass and I really need to get this element sorted once and for all.

      I also have turned on in Global Config the re-write element.

      Where am I going wrong anybody?

      Regards,
    • Last Edit: 11 years 10 months ago by oj09.
  • Re: SOLVED Force users to use http://www.yoursite.com problems?

    Posted 11 years 10 months ago
    • It's quite simple, use this in your .htaccess file:

      ### BEGIN redirect non-www to www ###
      RewriteEngine On
      RewriteBase /
      RewriteCond %{HTTP_HOST} ^YOURDOMAIN.com [NC]
      RewriteRule ^(.*)$ www.YOURDOMAIN/$1 [L,R=301]
      ### END redirect non-www to www ###

      You can add this anywhere in the .htaccess file.

      If you copy/paste this code, replace the YOURDOMAIN with your own, you'll be fine.

      Chris
    • CMYKreative : Graphic Design , Web Design , Printing , Banner Ads , Branding and more.
    • oj09's Avatar
    • oj09
    • Hero Rocketeer
    • Posts: 395
    • Thanks: 0

    Re: SOLVED Force users to use http://www.yoursite.com problems?

    Posted 11 years 10 months ago
    • Hi Chris,

      Thanks for the quick reply, I've tried using your one you kindly mentioned but still no joy.

      my current .htaccess looks like this;
      ##
      # @package       Joomla
      # @copyright     Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.
      # @license       GNU General Public License version 2 or later; see LICENSE.txt
      ##
       
      ##
      # 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.
      ##
       
      # Enable expirations
      ExpiresActive On
       
      # Default directive
      ExpiresDefault "access plus 1 month"
       
      # My favicon
      ExpiresByType image/x-icon "access plus 1 year”
       
      # Images
      ExpiresByType image/gif "access plus 1 month"
      ExpiresByType image/png "access plus 1 month"
      ExpiresByType image/jpg "access plus 1 month"
      ExpiresByType image/jpeg "access plus 1 month"
       
      # CSS
      ExpiresByType text/css "access 1 month”
       
      # Javascript
      ExpiresByType application/javascript "access plus 1 year"
       
      # compress text, html, javascript, css, xml:
      AddOutputFilterByType DEFLATE text/plain
      AddOutputFilterByType DEFLATE text/html
      AddOutputFilterByType DEFLATE text/xml
      AddOutputFilterByType DEFLATE text/css
      AddOutputFilterByType DEFLATE application/xml
      AddOutputFilterByType DEFLATE application/xhtml+xml
      AddOutputFilterByType DEFLATE application/rss+xml
      AddOutputFilterByType DEFLATE application/javascript
      AddOutputFilterByType DEFLATE application/x-javascript
       
      # Or, compress certain file types by extension:
       
      SetOutputFilter DEFLATE
       
      ## 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!
      #
      # 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.
      #
      ### BEGIN redirect non-www to www ###
      RewriteEngine On
      RewriteBase /
      RewriteCond %{HTTP_HOST} ^swswsws.co.uk [NC]
      RewriteRule ^(.*)$ http://www.swswsws/$1 [L,R=301]
      ### END redirect non-www to www ###
       
      ##
      # 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.
      #
      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 something within the component folder,
      # or for the site root, or for an extensionless URL, or the
      # requested URL ends with one of the listed extensions
      RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|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.
       
      CMYKreative wrote:
      It's quite simple, use this in your .htaccess file:

      ### BEGIN redirect non-www to www ###
      RewriteEngine On
      RewriteBase /
      RewriteCond %{HTTP_HOST} ^YOURDOMAIN.com [NC]
      RewriteRule ^(.*)$ www.YOURDOMAIN/$1 [L,R=301]
      ### END redirect non-www to www ###

      You can add this anywhere in the .htaccess file.

      If you copy/paste this code, replace the YOURDOMAIN with your own, you'll be fine.

      Chris
    • Ben Lee's Avatar
    • Ben Lee
    • Elite Rocketeer
    • Posts: 4193
    • Thanks: 42

    Re: SOLVED Force users to use http://www.yoursite.com problems?

    Posted 11 years 10 months ago
    • oj09's Avatar
    • oj09
    • Hero Rocketeer
    • Posts: 395
    • Thanks: 0

    Re: SOLVED Force users to use http://www.yoursite.com problems?

    Posted 11 years 10 months ago
    • Afternoon Ben,

      Thank you for your reply and time, it's much appreciated.

      To explain, when I purchased the SSL certificate, I selected www which at the time unbeknown to me is that then my hosting provider tells me that basically means my whole site is https:// protected now, as opposed to just select individual pages like it seems most people end up going for, like secure.mydomain.com/register for example.

      So as I'm having the SSL cart blanch across ALL pages, I don't think I need to use your 2nd link given in your last msg to me which is below, regarding menu elements.

      My hosting provider have told me what I need to do;
      Sorry, the site isn't redirecting swswsws.co.uk to www.swswsws.co.uk for me I'm afraid - how exactly have you set this up within Joomla? It's a non-standard thing so either special mod_rewrite code needs to be done in a .htaccess file otherwise I'm not aware Joomla provides this functionality but it's something I can envisage that is possible.

      It is however redirecting swswsws.co.uk/ to swswsws.co.uk/ though.

      With the whole site covered with an SSL I don't see it being an issue except that secured pages load slightly slower than non-secured pages.

      So as you can see, I need to sort a simple redirection out from swswsws.co.uk to www.swswsws.co.uk

      Any help or further guidance in this matter from anybody, would be so very much appreciated indeed.

      Regards,

      Ben Lee wrote:
      It looks like you're trying the right stuff. I've typed up a couple posts on htaccess stuff here:

      http://www.rockettheme.com/forum/index.php?f=92&t=46753&rb_v=viewtopic#p243473

      http://www.rockettheme.com/forum/index.php?f=92&t=145167&p=717897&rb_v=viewtopic#p717897

      The second one is how to force SSL or not included with the www.

      If these aren't working for you no matter what, Joomla 2.5 has their own "Redirects" extension that might be causing the issue for you. Check that in the admin backend and clear out any redirects that might be there, then make sure to clear cache and reload the page.
    • Ben Lee's Avatar
    • Ben Lee
    • Elite Rocketeer
    • Posts: 4193
    • Thanks: 42

    Re: SOLVED Force users to use http://www.yoursite.com problems?

    Posted 11 years 10 months ago
    • I still say to start with the fresh Joomla htaccess file and the go through the posts I linked to.

      When you use https that forces a full page load every time the page loads. This cancels out caching and other things that can really speed up your user experience. The way I have written the tutorial is for exacty what you're looking to do. Force "www" and then have "https" forced on the necessary menu items.

      Any page you go to you will be able to type in "https" or "http" and view the page in that way...unless you force those to be used.

      htaccess rules need to happen in a specific order for them to work properly, so that is why I've shared the rewrite rules I posted.

Time to create page: 0.077 seconds