URLs, htaccess and redirects

 

As Joomla is a database driven system the URLs it creates are actually queries sent to the database to retrieve content, which is why they often appear like complex algorithms. Search engines (such as Google, Yahoo and Bing) find these just as difficult to read as we do, which is why it is recommended that you adopt SEF URLs instead.

Transforming this…

http://www.hyde-design.co.uk/index.php?option=com_content&task=blogsection&id=0&itemid=4


Into this…

http://www.hyde-design.co.uk/search-engine-optimization

Search engines prefer these URLs because they're easier to read and can also include valuable keywords. To access the settings click on Site > Global Configuration.

Tick Yes next to “Search Engine Friendly URLS” and Yes again next to “Use Apache mod_rewrite”.

Then locate the “htaccess.txt” file within the root directory of your joomla installation…

…and rename it to “.htaccess” (don’t forget the full stop at the beginning).


Once this is done the file may seem to disappear (depending on what level of access your FTP client is set to) but it has done the job and all URLs and internal links to URLs will be replaced with SEF alternatives.


Warning: If your site starts to display 404 errors and suddenly lose style, then either the htaccess file has not been renamed or you have a serious problem with your web-host (ie. They are using Windows servers instead of Linux). In which case resetting the above should restore the state back to normal.


The wording of each link is then determined by the alias you have used for each menu item, so to change the URL title you have to go to Menu Manager, select your menu, open your menu item and rename the alias.

 

 

.htaccess

The hyper text access file (.htaccess) has already been mentioned, it is the text file that you need to rename for the SEF URLs to work.
One important function of the .htaccess file that most people overlook is the use of redirected URLS. If you are updating an old HTML based site in a Joomla format then any links that were recognised by Google are likely to become dead links (unless of course you are using exactly the same links, including the “.html” suffix). To avoid this add the following line to the bottom of the .htaccess file.


Redirect 301 /oldpage.html http://www.hyde-design.co.uk/newpage


Replacing “oldpage.html” with the old address and “http://www.hyde-design.co.uk/newpage” with the new address. This will ensure that any bookmarked pages or google ranked URLS are not lost in the redesign process.


As mentioned earlier, search engines treat the index.php file separately from your home page, they also treat the http://domain.com address separately from the http://www.domain.com address. Including the following code at the top of your .htaccess file will redirect any non-www pages to the relevant www page (don’t forget to replace text in red to your domain name).

Options +FollowSymLinks
DirectoryIndex index.php
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.hyde-design.co.uk/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
rewritecond %{http_host} ^hyde-design.co.uk [nc]
rewriterule ^(.*)$ http://www.hyde-design.co.uk/$1 [r=301,nc]

Web Design & Development
07845 950063
This email address is being protected from spambots. You need JavaScript enabled to view it.