iLLuSi0nS Posted June 9, 2008 Share Posted June 9, 2008 I figured it out, you have to change the / not only on the htaccess, but the tpl files as well. The reason the css and images are not working is because the rewrite makes the file look like its coming from a folder, and since that folder is not the root, it cant load the template files. 0 Quote Link to comment Share on other sites More sharing options...
iLLuSi0nS Posted June 9, 2008 Share Posted June 9, 2008 I am trying to optimize announcements.php and I am almost there. what does this part do? id=$2 [L,NC] especially the [L,NC] what does that do? and what about the id=$2 Thanks 0 Quote Link to comment Share on other sites More sharing options...
rmccny Posted June 9, 2008 Share Posted June 9, 2008 [L,NC] = Last rule (stop matching additional rules), No Case (case insensitive) id=$2 = Sets the ID to the second parameter matched by the rule. This in effect passes the value matched by $2 as $_GET[id] to php. Hope that helps. 0 Quote Link to comment Share on other sites More sharing options...
Serverweb Posted June 9, 2008 Share Posted June 9, 2008 Nothing.. now i ask to a "php-builder"...( my whmcs is into /panel therefore the real link is http://www.domainxx.tld/panel/knowledgebase.php i put into .htaccess (under puclic_html/ ) this code (i try with / , with _ , without /panel, etw) RewriteEngine On RewriteRule ^knowledgebase/([0-9]+)/([0-9]+)/[a-z0-9/-]+\.html$ /panel/knowledgebase.php?action=displayarticle&catid=$1&id=$2 [L,NC] RewriteRule ^knowledgebase/([0-9]+)/([^/]*)$ /panel/knowledgebase.php?action=displaycat&catid=$1 [L,NC] into knowledgebase.tpl and knowledgebasecat.tpl i put <a class="menu" href="/knowledgebase/{$kbcat.id}/{$kbcat.name|regex_replace:"/ /":"_"|regex_replace:"/[\?\'\.\,\!]/":""}"> <img src="images/support/folder.gif" border="0" align="middle" alt="" /> {$kbcat.name}</a></strong> ({$kbcat.numarticles})<br /> and <a href="/knowledgebase/{$kbarticle.category}/{$kbarticle.id}/{$kbarticle.title|regex_replace:"/ /":"_"|regex_replace:"/[\?\'\.\,\!]/":""}.html">{$kbarticle.title}</a> but not fine:( 0 Quote Link to comment Share on other sites More sharing options...
Serverweb Posted June 19, 2008 Share Posted June 19, 2008 Hi where i wrong? thanks 0 Quote Link to comment Share on other sites More sharing options...
dreamcon Posted June 20, 2008 Share Posted June 20, 2008 thanks for the amazing contribution.. I will try it today itself 0 Quote Link to comment Share on other sites More sharing options...
BenHarris Posted June 25, 2008 Share Posted June 25, 2008 Hey all. Has anyone managed to get the relative links problem working. At the moment, our seo friendly URLS look something like this /knowledgebase/7/53/Attachments.html does anyone know if it would be possible to change the same thing to something like /knowledgebase-7-53-Attachments.html which would thus fix the relative links problem and maintain the data, and keep them fairly friendly. Ben 0 Quote Link to comment Share on other sites More sharing options...
bookandhost Posted July 2, 2008 Share Posted July 2, 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 Hi! I tried the same way that was specified,ok the .htaccess file didnt give any error as i have changed id spacing thing and thats solved, but now my problem is as you specified i have two tpl files knowledgebase and knowledgebasecat, you are telling me to replace the existing lines with your lines, but i dont find the existing lines anywhere, i am using latest version whmcs3.6.2, can you please guide me the process? 0 Quote Link to comment Share on other sites More sharing options...
Redundant Posted July 5, 2008 Share Posted July 5, 2008 Hey Folks, Great contribution! Like another guy, I got the internal 500 error. When indicating the ROOT .htaccess file, does this mean the Root WHMCS folder? /public_html/whmcs/.htaccess ? 0 Quote Link to comment Share on other sites More sharing options...
Redundant Posted July 5, 2008 Share Posted July 5, 2008 Can't edit my post. Sorry, meant I am getting 404 errors. Not 500. Ideas on the 404s? 0 Quote Link to comment Share on other sites More sharing options...
goddess_dix Posted July 6, 2008 Share Posted July 6, 2008 404 errors, somethings wrong either in your .htaccess expressions or in the links. look at the web address you're getting to in order to troubleshoot. for those getting the stuff to work without styling in the articles, adding the following to the head code of their header template file setting the base will fix it. since all the whmcs stuff shows as being from the same folder, structurewise, this doesn't break anything. <base href="http://whmcs.domain.com/" /> whatever your domain is, of course. call this BEFORE any style sheet or javascripts, etc. to maintain the path. 0 Quote Link to comment Share on other sites More sharing options...
goddess_dix Posted July 6, 2008 Share Posted July 6, 2008 also on the 404, is it for an article that has an ampersand or other unusual character in the title? may not be accounted for in the reg. expression in htaccess... 0 Quote Link to comment Share on other sites More sharing options...
arteryplanet Posted July 7, 2008 Share Posted July 7, 2008 404 errors, somethings wrong either in your .htaccess expressions or in the links. look at the web address you're getting to in order to troubleshoot. for those getting the stuff to work without styling in the articles, adding the following to the head code of their header template file setting the base will fix it. since all the whmcs stuff shows as being from the same folder, structurewise, this doesn't break anything. <base href="http://whmcs.domain.com/" /> whatever your domain is, of course. call this BEFORE any style sheet or javascripts, etc. to maintain the path. This do not break the http and https switch? 0 Quote Link to comment Share on other sites More sharing options...
goddess_dix Posted July 7, 2008 Share Posted July 7, 2008 This do not break the http and https switch? nope, this worked fine for me. if you think about it, all it's doing is making the links for seo-friendly page based out the main whmcs folder instead of appearing to be in imaginary folders you're setting up with the new links. because the other pages are already showing as being in the main whmcs folder, it's no effective change on most pages. 0 Quote Link to comment Share on other sites More sharing options...
arteryplanet Posted July 8, 2008 Share Posted July 8, 2008 Hi Goddess_dix, I did test it again and i do confirm this break it if you are using https as declaring the base as non ssl is confusing the system and is acting up in some areas. Any other way to correct the styling problem? Thanx! 0 Quote Link to comment Share on other sites More sharing options...
goddess_dix Posted July 9, 2008 Share Posted July 9, 2008 can you give me an example of where it's messing up for you? because mine is working just fine, so i'm wondering if i'm missing something or there is something set up differently for you... 0 Quote Link to comment Share on other sites More sharing options...
arteryplanet Posted July 9, 2008 Share Posted July 9, 2008 sure....after i did add the base url in the header template if you login as a user through the admin panel, then click in the My hosting packages ---> View details. This keep me loading the Home page instead to show me the hoting package details. Same issue with My domains --> View details. Just removing the base tag from the header template is correcting this so thats the cause. 0 Quote Link to comment Share on other sites More sharing options...
goddess_dix Posted July 9, 2008 Share Posted July 9, 2008 ohhhhh. i was having problems with the view details and NOT connecting it to that...lmao... thank you. so much for that idea.... /shakes head at self. 0 Quote Link to comment Share on other sites More sharing options...
arteryplanet Posted July 9, 2008 Share Posted July 9, 2008 no problem....now the point is to find a solution...i havent yet :-( 0 Quote Link to comment Share on other sites More sharing options...
Troy Posted July 9, 2008 Share Posted July 9, 2008 If you want to use the base href thing but have it handle both secure and non-secure URLs, here's a snippet of code that should work: <?php $site = "www.domain.com/"; // replace with your site $prefix = ($_SERVER['SERVER_PORT'] == '80') ? 'http://' : 'https://'; echo '<base href="'.$prefix.$site.'" />'; ?> Put that in a file named basehref.php, put it in your WHMCS root, and then in your header.tpl template add: {include_php file="basehref.php"} 0 Quote Link to comment Share on other sites More sharing options...
arteryplanet Posted July 9, 2008 Share Posted July 9, 2008 Thanx Troy, Yes that should work, i was testing another way to avoid have that file in my root. Just using this code in the header.tpl do the trick: {php} $http_mode = (!empty($_SERVER['HTTPS'])) ? 'https://' : 'http://'; $my_url = $http_mode . $_SERVER['HTTP_HOST']; echo '<base href=/"$my_url/" />'; {/php} 0 Quote Link to comment Share on other sites More sharing options...
arteryplanet Posted July 9, 2008 Share Posted July 9, 2008 how i could edit the code...i have an error there.... anyway the base url is changing ok but this is not fixing the problem i have posted before, not sure why is happening.....im not finding a way to resolve the styling problem. 0 Quote Link to comment Share on other sites More sharing options...
magga Posted July 10, 2008 Share Posted July 10, 2008 For those of you having issues with your knowledgebase relative links etc and tried the above but then it messes up other pages (SSL pages etc) you can do this instead: in header.tpl add between <head> and </head>: {if $pagetitle eq "Knowledgebase"} <base href="http://www.domain/WHMCS INSTALL PATH" /> {/if} this will then only force the base href on the knowledgebase page! 0 Quote Link to comment Share on other sites More sharing options...
arteryplanet Posted July 10, 2008 Share Posted July 10, 2008 Very easy solution, ill test it out...i was doing very complex things to try to fix it. lol. I ended up changing to _ instead to / as someone did mention few post before, but ill test this also. Thank you! 0 Quote Link to comment Share on other sites More sharing options...
arteryplanet Posted July 10, 2008 Share Posted July 10, 2008 btw....keep in mind to add more "if" if you are using multiple languages. 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.