Joomla Mod Rewrite & 500 Errors - Problems and Solutions
The time always comes in a web developer's life when they are working on a redesign or upgrade of an existing site. This is generally a more rewarding project, as the knowledge gleaned from the lifespan of the existing site provides much valuable information for the new developMent. This is also a double edged sword as we must also be careful not to upset our existing search engine visibility and all old pages must be redirected to new pages.
This is achieved through the use redirection and issuing the HTTP 301 status code which indicates the resource has moved permanently.
URL Rewriting with Joomla!
If you are moving to a Joomla! site or simply updating the structure of an existing Joomla installation then you will need to dive into the murky world of URL rewriting with .htaccess. Things are a little more tricky if you are using Joomlas search engine friendly URL system as you have to be careful not to upset any of the existing rules so knowing what you are doing can (and will) save you a whole bunch of headaches.
If you are not using the URL rewriting system in Joomla! then you will need to add a .htaccess file and simply add your mod rewrite rules. If you are looking to add rules to an existing Joomla .htaccess file then you will need to be a little more careful.
Adding Rewrite Rules to Joomla .htaccess
The Joomla.htaccess file is clearly marked up showing three distinct areas. You want to place your rules after the block that is comMented as 'Rewrite rules to block out some common exploits' and before the block that is comMented 'Begin - Joomla! core SEF Section'.
The following shows where are new rules are to go, the exact text may be slightly different or there may be additional comMents but this should help you identify correct place to add your new rules.
########## End - Rewrite rules to block out some common exploits
########### new rules go here
# rewrite oldpage1.html to site root
rewriterule ^oldpage1\.html$ / [R=301,L]
# rewrite oldpage2.html to newpage.html
rewriterule ^oldd-page.html /newpage.html [R=301,L]
########### new rules end here
########## Begin - Joomla! core SEF Section
Common Problems - Joomla 500 Error
There are lots of other.htaccess problems that can generate the dreaded 500 internal server error. Things vary between different web server configurations so there are no concrete answers but the following are some of the most common problems and solutions.
1. Options +FollowSymLinks
Try adding or removing this line
2. RewriteBase /
If you rules are causing problems, try adding or removing 'RewriteBase /'
3. L = Last Rule
Always make sure your 301 rewrites include the optional L flag ([R=301,L]) to indicate that this is the last rule.
On a more general note, if you have problems then comment your rewrite rules, un-comment them one at a time and test till you find the culprit. Nine times out of ten you will find that your problem lies in small error in the syntax or at the very least by identifying the exact problem you can request or search for targeted help.
Better now?
Mod Rewrite is a powerful tool but the syntax can be confusing and troublesome for casual users. Combine that with the general purpose 500 internal server error and you have a recipe for confusion and lost time.
Joomla Mod Rewrite & 500 Errors - Problems and Solutions
Joomla Mod Rewrite & 500 Errors - Problems and Solutions
No comments:
Post a Comment