0
Welcome Guest! Login
0 items Join Now

htaccess redirection

  • htaccess redirection

    Posted 14 years 1 month ago
    • Hi there.

      I was looking to redirect all requested URL addresses not containing "www." to www. type addresses in my Joomla website, but I am too much of a newbie to handle this on my own...
      Regarding configuration, I have Joomla SEF and mod_Rewrite enabled and the site's addresses contain greek characters (if that makes any difference...on one of the following links there is a suggestion that it does make a difference)

      I have tried doing this with the Redirect plugin I have installed, but it does not work...I had " domain.com " point to " www.domain.com " with no result...It seems it does work when the requested page is actually available on the site

      I searched for answers at Joomla.org threads but I was unsure concerning the exact implementation..

      E.g. in this page I found the following code, but it's not clear to me what of the following I must use and what I have to leave out...(I guess the first part is the most important)
      ########## Begin - 301 Redirect
      Options +FollowSymLinks 
      RewriteEngine on 
      RewriteCond %{HTTP_HOST} ^yoursite\.com$ [NC]
      RewriteRule .* http://www.yoursite.com/ [L,R=301]
      #
      RewriteEngine On
      RewriteBase /
      RewriteCond %{HTTP_HOST} !^www\.yoursite\.com$
      RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R=301,L]
      RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
      RewriteRule index\.php$ http://www.yoursite.com/%1 [R=301,L]
      #
      RewriteCond %{QUERY_STRING} ^option=com_frontpage&Itemid=1$ 
      RewriteRule ^index\.php$ http://www.yoursite.com/? [R=301,L]
      ########## End - 301 Redirect


      Also, I found this page where a part of the previous code is used - yet being somewhat different (the "$" is missing at the end of the first line, on the second line the part after "RewriteRule" is different and the "L" follows the "=301" at the end.
      RewriteCond %{HTTP_HOST} ^yoursite\.com [NC]
      RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R=301,L]


      I also made a search in RT forums. In this page I found the following code proposed....this one misses the "$" on the first line with regard to the first example and the "[NC]" with regard to the second, as well as the slash "\" before the ".com" with regard to both AND the part after "RewriteRule" is different from both above examples and differs from the first one at the end - "L" follows "301"...
      RewriteEngine On
      RewriteCond %{HTTP_HOST} ^yourdomain.com
      RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]

      What do all these differences mean and what are their different consequences?

      The contents of my own .htaccess file are the following
      ## EOMBAK - Do not remove this line or this file
      ##
      # @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 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
      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
       
      RewriteCond %{HTTP_REFERER} !^http://domain.com/.*$      [NC]
      RewriteCond %{HTTP_REFERER} !^http://domain.com$      [NC]
      RewriteCond %{HTTP_REFERER} !^http://www.domain.com/.*$      [NC]
      RewriteCond %{HTTP_REFERER} !^http://www.domain.com$      [NC]
      RewriteCond %{HTTP_REFERER} !^http://www.domain.com/forum/.*$      [NC]
      RewriteCond %{HTTP_REFERER} !^http://www.domain.com/forum$      [NC]
      RewriteRule .*\.(.*)$ http://www.domain.com [R,NC]
       
       
      If you look at the above code, you will also find at the bottom a part that I am under the impression it was planted there either by Rockettheme's Rokbridge component (which I have now uninstalled) OR by the Kunena forum I am now operating, where I have enabled all SEF relevant options in its configuration...

      Could you help me out?

      Million thanks...
    • You can call me George
      J2.5.8, Panacea v1.6.6 - www.eks-ik.eu
      J2.5.8, Syndicate 1.6.5
  • Re: htaccess redirection

    Posted 14 years 1 month ago
    • I had posted this topic also at joomla.org and a developer who has been working on optimizing the htaccess file responded, giving me the following code
      RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
      RewriteRule (.*) http://www.example.com/$1 [R=301,L]

      I actually used his whole new htaccess file he has posted at joomlacode, which is probably going to be included in the newer Joomla versions.
      I confirm that it works and that my site has indeed become more responsive for sure...

      You can find his Joomla 1.5 file here joomlacode.org/gf/project/joomla/tracker...racker_item_id=25090
      and his Joomla 1.6 file here joomlacode.org/gf/project/joomla/tracker...racker_item_id=22425
    • You can call me George
      J2.5.8, Panacea v1.6.6 - www.eks-ik.eu
      J2.5.8, Syndicate 1.6.5

Time to create page: 0.071 seconds