jasonBV Posted January 7, 2008 Share Posted January 7, 2008 Below are the steps I took to setup setup mod_rewrite and what files need to be modified for SEO friendly links. What is a SEO friendly link? Here's an example. Normal knowledgebase url: /knowledgebase.php?action=displayarticle&catid=1&id=1 Friendly URL: /knowledgebase/1/1/This_is_my_help_article.html Note that if you're rewriting your links with extra directories, you will have to be careful of any relative links you have such as javascript or style includes. My regular expressions are a little rusty, so I make no guarantees that this will work 100% for everyone If anyone has a better way to do this feel free, but I found it to be a little difficult with only template access. 1) Make sure you have mod_rewrite installed and access to add .htaccess options. 2) Add the following to your root .htaccess file: RewriteEngine On RewriteRule ^knowledgebase/([0-9]+)/([0-9]+)/[a-z0-9_-]+\.html$ /knowledgebase.php?action=displayarticle&catid=$1&id=$2 [L,NC] RewriteRule ^knowledgebase/([0-9]+)/([^/]*)$ /knowledgebase.php?action=displaycat&catid=$1 [L,NC] 3) Open your knowledgebase.tpl file and modify the article links to the following: <a href="/knowledgebase/{$kbarticle.category}/{$kbarticle.id}/{$kbarticle.title|regex_replace:"/ /":"_"|regex_replace:"/[\?\'\.\,\!]/":""}.html">{$kbarticle.title}</a> Change the knowledgebase category links to the following: <a class="menu" href="/knowledgebase/{$kbcat.id}/{$kbcat.name|regex_replace:"/ /":"_"|regex_replace:"/[\?\'\.\,\!]/":""}"> 4) Do the same with the knowledgebasecat.tpl and change the article links as above. You can use thing for custom cart URLs, just modify the links in the TPL file and .htaccess file. Here's an example of my setup: http://www.bargainvoice.com/knowledgebase.php 0 Quote Link to comment Share on other sites More sharing options...
internetbrother Posted January 7, 2008 Share Posted January 7, 2008 thanks can you exactly please type what to find in tple 0 Quote Link to comment Share on other sites More sharing options...
jasonBV Posted January 7, 2008 Author Share Posted January 7, 2008 If you're using the default knowledgebase templates, your article link will look like this: <a href="knowledgebase.php?action=displayarticle&catid={$kbarticle.category}&id={$kbarticle.id}">{$kbarticle.title}</a> Original category links look like: <a href="knowledgebase.php?action=displaycat&catid={$kbcat.id}"><img src="images/support/folder.gif" border="0" align="middle" alt="" /> {$kbcat.name}</a> 0 Quote Link to comment Share on other sites More sharing options...
alesf77 Posted January 7, 2008 Share Posted January 7, 2008 This is very nice solution. I hope it will get in whmcs release in next versions. I made all changes as described, but I got "500 Internal Server Error". I seems it got something to to with On .htaccess File Apache. I made some google search but, i haven't found any solution on this. Any idea? 0 Quote Link to comment Share on other sites More sharing options...
jasonBV Posted January 8, 2008 Author Share Posted January 8, 2008 This is very nice solution. I hope it will get in whmcs release in next versions. I made all changes as described, but I got "500 Internal Server Error". I seems it got something to to with On .htaccess File Apache. I made some google search but, i haven't found any solution on this. Any idea? It sounds like either mod_rewrite isn't installed or you have something wrong in the .htaccess file causing it to error. There should be an error message in your webserver logs. 0 Quote Link to comment Share on other sites More sharing options...
amnesia Posted January 10, 2008 Share Posted January 10, 2008 something like this needs to be in whmcs by default.. I'm surprised it isn't yet 0 Quote Link to comment Share on other sites More sharing options...
davet Posted January 11, 2008 Share Posted January 11, 2008 yes it would be nice if there was an option that you could turn search engine friendly URLs on or off... like you can with joomla. You'd still have to edit your .htaccess file but it would be helpful if you didn't need to edit your template files. 0 Quote Link to comment Share on other sites More sharing options...
UH-Matt Posted January 11, 2008 Share Posted January 11, 2008 What a fantastic contribution, just what I was looking for for when we go live with whmcs! Thanks, 0 Quote Link to comment Share on other sites More sharing options...
UH-Matt Posted January 11, 2008 Share Posted January 11, 2008 Ideally it would be great if this could be taken by Matt and made part of the default release, maybe just with a configuration "ON/OFF" for SEO friendly url's at least then we dont go ahead and use this, then when it gets added to whmcs all our url's for KB articles change yet again... 0 Quote Link to comment Share on other sites More sharing options...
Tech Entrance Posted January 11, 2008 Share Posted January 11, 2008 It will be nice if the page title become as the same as article title as well (extra SEO friendly). Nice contribution you have there buddy 0 Quote Link to comment Share on other sites More sharing options...
Gareth-HFX Posted January 18, 2008 Share Posted January 18, 2008 I agree that this should be in WHMCS by default. Great contribution. 0 Quote Link to comment Share on other sites More sharing options...
Jordan Posted January 21, 2008 Share Posted January 21, 2008 I haven't had the time (or patience) to do this myself, so I'm definitely glad that you took the time to put this together. Of course I'm going to mod it a bit, since I don't like the trailing extension, but otherwise, thanks! :oP 0 Quote Link to comment Share on other sites More sharing options...
seo_india Posted February 1, 2008 Share Posted February 1, 2008 That was very informative. Thanx @jason. 0 Quote Link to comment Share on other sites More sharing options...
rslyon Posted February 6, 2008 Share Posted February 6, 2008 Hi, We support mod_rewrite however when i add the two lines: RewriteRule ^knowledgebase/([0-9]+)/([0-9]+)/[a-z0-9_-]+\.html$ /knowledgebase.php?action=displayarticle&catid=$1&i d=$2 [L,NC] RewriteRule ^knowledgebase/([0-9]+)/([^/]*)$ /knowledgebase.php?action=displaycat&catid=$1 [L,NC] we also get the 500 error. 0 Quote Link to comment Share on other sites More sharing options...
eunarede Posted February 6, 2008 Share Posted February 6, 2008 I get the 500 error to... 0 Quote Link to comment Share on other sites More sharing options...
jasonBV Posted February 7, 2008 Author Share Posted February 7, 2008 You will want to check your web server error logs to see what error is being thrown. 0 Quote Link to comment Share on other sites More sharing options...
opt2bout Posted February 15, 2008 Share Posted February 15, 2008 You will want to check your web server error logs to see what error is being thrown. Great tip! I do wish this was in the base system so we wouldn't have to use .htaccess. Anyway, RewriteRule ^knowledgebase/([0-9]+)/([0-9]+)/[a-z0-9_-]+\.html$ /knowledgebase.php?action=displayarticle&catid=$1&i d=$2 [L,NC] Has a space between "&i" and "d=$2" near the end of the line. You are probably getting 500 errors (specifically in your error logs... htaccess: RewriteRule: bad flag delimiters). Remove the space and you should be okay. RewriteRule ^knowledgebase/([0-9]+)/([0-9]+)/[a-z0-9_-]+\.html$ /knowledgebase.php?action=displayarticle&catid=$1&id=$2 [L,NC] Thanks again for the tip, its working great! 0 Quote Link to comment Share on other sites More sharing options...
honesting Posted March 5, 2008 Share Posted March 5, 2008 When I do that the style, images, etc, don't load correctly. Any idea about this? 0 Quote Link to comment Share on other sites More sharing options...
tracktor Posted March 5, 2008 Share Posted March 5, 2008 try with absolute path 0 Quote Link to comment Share on other sites More sharing options...
eunarede Posted March 5, 2008 Share Posted March 5, 2008 http://eunarede.com/cliente/knowledgebase/4/Servi%E7os The cause for which my pages have been so? As the above? 0 Quote Link to comment Share on other sites More sharing options...
eunarede Posted March 5, 2008 Share Posted March 5, 2008 http://eunarede.com/cliente/knowledgebase/4/Servi%E7os The cause for which my pages have been so? As the above? http://eunarede.com/cliente/knowledgebase/1/Dicas.rede 0 Quote Link to comment Share on other sites More sharing options...
gasmoney Posted March 5, 2008 Share Posted March 5, 2008 Make sure the syntax is right sometimes an extra character can create the 500 server error 0 Quote Link to comment Share on other sites More sharing options...
eunarede Posted March 5, 2008 Share Posted March 5, 2008 All the images and CSS are broken, the page open, dont have 500 server error, but the css and the images do not apers. 0 Quote Link to comment Share on other sites More sharing options...
minadreapta Posted March 6, 2008 Share Posted March 6, 2008 All the images and CSS are broken, the page open, dont have 500 server error, but the css and the images do not apers. try to use underscore instead of slash: "_" instead of "/" like this: RewriteRule ^knowledgebase_([0-9]+)_([0-9]+)_[a-z0-9_-]+\.html$ /knowledgebase.p hp?action=displayarticle&catid=$1&id=$2 [L,NC] try this solution 0 Quote Link to comment Share on other sites More sharing options...
eunarede Posted March 6, 2008 Share Posted March 6, 2008 try to use underscore instead of slash: "_" instead of "/" like this: RewriteRule ^knowledgebase_([0-9]+)_([0-9]+)_[a-z0-9_-]+\.html$ /knowledgebase.p hp?action=displayarticle&catid=$1&id=$2 [L,NC] try this solution Works perfectly!! Now I need solve the problem of replacement of accents by letter without the accent (eg "é" by "e" and, "á" by "a"). Thanks! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.