| Joomla, CPanel and Redirects |
|
| Written by Xuro |
| Wednesday, 17 February 2010 09:40 |
|
The Vision I have a vision for the Funplosion web site - ultimately i would like the site to be a source for high quality game development information (particularly for people making Xbox Live Indie games through the XNA Creator's Club). With that in mind, my end goal is to have some "destination" pages, the sort of high quality pages with compelling content that might draw people to my site and spawn copious links and bookmarks. There are three things that I view as integral pieces to (hopefully) making that happen: 1) Compelling quality content (outside the scope of this article, but feel free to visit funplosion.com/free and funplosion.com/toolbox and let me know if I'm on the right track!) 2) Permanent article links, so that any web links or bookmarks that do get created stay relevant. 3) Short, human-friendly URLs
(I'm always on the prowl for a better permalink solution - got one? The comments yearn for your input!)
I still haven't figured out a good way to make all of my links "permalinks" (persistent despite upgrades/changes in my CMS), but as an interim measure I decided to use redirects to provide permalinks for the articles I've put the most effort into. For example rather than having a URL like XYZ.com/section/category/LotsOfGreatInfo.html, I can use a redirect and send any visitor to XYZ.com/info to the longer URL. While this approach is a bit cumbersome and requires manually adding a redirect for each piece of content for which you want the permalink, it has the benefit that if the actual URL for the article ever changes, I can simply update the redirect and people going to XYZ.com/info will still end up in the right place. Note that people who bookmarked the long-form of the URL would still end up with a broken link, which would require another redirect to address... I don't have a good solution for that yet, other than just never ever changing my CMS, which may not be practical). But regardless, the redirect scratches the short-term itch and allows me to provide some human-friendly URLs right out of the gate.
Vision meets glitch (aka why isn't my redirect working!?) My initial attempt at a redirect failed, and kept resulting in 404 "page not found" errors. This was even though the page I was redirecting to did indeed exist and typing the URL in manually or following it from a link worked! It was only when arriving via the redirect that it failed... the address bar would be correct but in place of my finely crafted destination page was the ugly default 404 page. (Note to self: replace the ugly default 404 page). After some troubleshooting of my own to no avail, I contacted my web host's support chat who was able to point out the problem - a conflict between Joomla and the redirect. In a nutshell, both Joomla and Redirects do things in the .htaccess file to help get people to the correct web page.
Redirects - Whether you manually add a redirect to your .htaccess file or use an interface such as CPanel, the end result is the same: some lines are added to your .htaccess that send anyone visiting page A to page B instead. Joomla SEF URLs - Joomla by default has fairly long ugly URLs (stuff like xyz.com/index.php?option=com_content&Itemid=2). Fortunately, Joomla also has built-in SEF (search-engine friendly) URLs which can be enabled. This "changes" your URLs to be more readable like xyz.com/section/category/news.htm. This is accomplished by, you guessed it, adding some lines to the .htaccess file to help effect the URL change.
Resolution With it all layed out like this, the nature of the problem becomes pretty clear. The order in which things exist in the .htaccess file is important. In my case, the Joomla section was before my 302 redirect so essentially Joomla would get a hold of the short URL (XYZ.com/info) and determine that the page didn't exist, then the redirect would happen and the URL was updated but it was too late. The fix was to go into the .htaccess file and move the lines for any 301/302 redirects to the top of the file before the Joomla SEF code, as shown below.
I'm curious how other people tackle this issue of providing static permalinks into your content - feel free to share your solutions in the comments or contact me directly.
RewriteEngine On ########## ...my redirects RewriteCond %{HTTP_HOST} ^funplosion.com$ [OR] RewriteCond %{HTTP_HOST} ^www.funplosion.com$ RewriteRule ^free$ "http\:\/\/www\.funplosion\.com\/free\-assets\.html" [R=301,L] ########## ...end of my redirects # ...lots of unrelated stuff ########## Begin - Joomla! core SEF Section # ...All the rules that make the search-engine friendly URLs work ########### End - Joomla! core SEF Section
|
| Last Updated on Saturday, 20 February 2010 16:08 |

