extensions.Siliana.com

Home arrow sh404SEF arrow Documentation arrow .htaccess files information
Please make a small donation
(big donation ok too)
.htaccess files information

Sometimes, it can be difficult to find the right settings!

    Prior to being able to use sh404SEF, your Joomla installation must be able to rewrite URL. This is something that is not related to Joomla, but rather to your Apache server. Making it work may be a breeze, or a nightmare. As stated elsewhere, I would definitively advice you to request assistance from your hosting company for this matter, as they are the ones who set up your Apache server and knows about its setting.

Please note that starting with version 1.2.4.s, sh404SEF can also operate completely WITHOUT any .htaccess. From version t, this is even the default configuration. 

Still, I have listed here a few pieces of information you may find useful in the process of setting up URL rewriting for your site.

Check if URL rewriting works 

First thing first : you want to know if that thing works on your server. You can do two things :

  • Within JOOMLA : in the backend, go to System menu, then System information. On the PHP tab, just run a search for the word 'rewrite'. If you don't find anything, then mod_rewrite (an Apache module in charge of doing URL rewirting) is not loaded and nothing will work. You need to change your Apache web server httpd.conf file, or contact your system administrator or shared host company to do this for you.
  • Outside of Joomla :
    • Using ftp, go to your web site root directory. Locate an existing .htaccess file. If there is one, then load it up in a text editor, otherwise, create a new .htaccess file there
    • At the very top of this file, type in the single following line:
redirect /google http://www.google.com
    • Save the file, then open up your browser and go to yoursite.com/google, replacing yoursite.com by your web site address
    • You should be redirected automatically to the Google homepage. If not, then again you need to change your Apache web server httpd.conf file, or contact your system administrator or shared host company to do this for you

Finding the right .htaccess

    The .htaccess file that will work for you is tightly related to your hosting company and hosting plan.

  • Joomla standard .htaccess is very FINE. It will work with a  lot of hosting companies. You should use it unmodified, at least to start with. Just remember it comes named as htaccess.txt, so you need to rename it to .htaccess before anything.
  • Joomla standard .htaccess comes configured for Joomla standard SEF system (which makes sense!). To use it with sh404SEF (or OpenSEF, Artio JoomSEF, SEF Advance), you must open it up in an editor, and make the few changes explained in it:
    If you scroll down towards the end of the file, you'll see two sections, one marked Begin - Joomla! core SEF Section, and just next to it another marked : ########## Begin - 3rd Party SEF Section
    Now the tricky part : you should type # at the beginning of each line of the first section, and remove those # in front of those in the second section, so that the whole things looks like :

########## Begin - Joomla! core SEF Section
############# Use this section if using ONLY Joomla! core SEF
## ALL (RewriteCond) lines in this section are only required if you actually
## have directories named 'content' or 'component' on your server
## If you do not have directories with these names, comment them out.
#
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR] ##optional - see notes##
#RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$ [NC]
#RewriteRule ^(content/|component/) index.php
#
########## End - Joomla! core SEF Section


########## Begin - 3rd Party SEF Section
############# Use this section if you are using a 3rd party (Non Joomla! core) SEF extension - e.g. OpenSEF, 404_SEF, 404SEFx, SEF Advance, etc
#
RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR] ##optional - see notes##
RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php
#
########## End - 3rd Party SEF Section

Note : this is from the .htaccess that comes with Joomla 1.0.12. If you are using a more recent version of Joomla, in the 1.0.x series, use the latest version of the file instead of this one.
  • If you get 404 errors or Internal error 500, or similar, when clicking on a rewritten URL, then you should try adding another # at the beginning of this line (near the top of the file):
Options FollowSymLinks
so that it looks like:
#Options FollowSymLinks
  • Alternatively, you can also try to replace:
Options FollowSymLinks
and add a + sign as follow:
Options +FollowSymLinks
  • If that does not work, and if your Joomla site is in a sub-directory, you should look for the line that looks like:
#RewriteBase /
and replace it with :
RewriteBase /sub_directory_of_your_joomla_install
  • On some servers, even if your site is not in a sub-directory, you may want to try replacing
#RewriteBase /
by
RewriteBase /
  • One little thing more : try changing only one thing at a time, and check the result before moving to next step

Suggested addition to .htacces

    For apache, the .htaccess file that comes with Joomla is FINE!! However, there is just one line I would suggest you add to it:

# Rule for duplicate content removal : www.domain.com vs domain.com
RewriteCond %{HTTP_HOST} ^mydomain\.com [NC]
RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L,NC]

    What this will do is rewrite all page requests starting with mydomain.com to www.mydomain.com. This way, you will avoid some duplicate contents issues (even though that is not really a problem nowadays, at least with Google), and also improve the way many editors, including JCE, will behave.

You should replace mydomain\.com on the first line and www.mydomain.com by your own domain information of course.
Also, you should place these 3 lines just after the RewriteBase line in Joomla standard .htaccess file.
Lastly, you can also do it the other way around, that is rewrite www.mydomain.com to mydomain.com. To do this, simply use :

# Rule for duplicate content removal : domain.com vs wwwdomain.com
RewriteCond %{HTTP_HOST} ^www.mydomain\.com [NC]
RewriteRule (.*) http://mydomain.com/$1 [R=301,L,NC]

 

 
Advertisement