Jump to content

Make whcms SEO friendly


powerhoster

Recommended Posts

Most every URL can be rewritten if you have the mind to do it however you have to ask yourself why would you want to rewrite all the URLs. We make all our main pages and product listing pages SEO friendly but there is no reason for search engines to need to spider pages within the order process.

 

The whole process however does need you to know something about mod_rewrite rules and the WHMCS template system it is not built into WHMCS apart from the knowledge base (which we don't use anyway as it is not multi-lingual).

Link to comment
Share on other sites

  • 2 weeks later...

Sure there is, if you know the URL then simply rewrite it in your .htaccess e.g.

 

RewriteRule ^panel/order-linux-hosting.htm /panel/cart.php?gid=3 [NC,LP,QSA] 

 

With a little work you could also alter the templates to generate automatic seo urls.

 

First create a smarty plugin modifier, in \includes\smarty\plugins\ create a blank text file called "modifier.str2seourl.php" and add the following code to it -

 


<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/

/**
* Smarty lower modifier plugin
*
* Type:     modifier<br>
* Name:     str2seourl<br>
* Purpose:  converts a string to SEO friendly url.
* @link http://www.servwise.com
* @author   Sam Morgan
* @param string
* @return string
*/
function smarty_modifier_str2seourl($string)
{
$separator = "-";
$string = trim($string);
$string = strtolower($string); // convert to lowercase text

// Only space, letters, numbers and underscore are allowed

$string = trim(ereg_replace("[^ A-Za-z0-9_]", " ", $string));
$string = ereg_replace("[ tnr]+", "-", $string);
$string = str_replace(" ", $separator, $string);
$string = ereg_replace("[ -]+", "-", $string);

return $string;
}
?>

 

Then look in your /orderforms/xxx/products.tpl template. (xxx is the template style you are using) and find the code for generating the links. e.g.

 


<input type="button" value="{$LANG.ordernowbutton}"{if $product.qty eq "0"} disabled{/if} onclick="window.location='{$smarty.server.PHP_SELF}?a=add&pid={$product.pid}'" />

 

modify it to create seo friendly links using the product title.

 

{if $product.qty eq "0"}
<a href="#" class="nobuylink">Out of Stock</a>
{else}
<a href="/order/{$product.pid}/{$product.name|str2seourl}.htm" class="buylink">Order now</a>
{/if} 

 

In your .htaccess add the following line (Replace whmcs with the folder where whmcs is installed)

 


RewriteRule ^order/(.*)/(.*).htm /whmcs/cart.php?gid=$1 [NC,LP,QSA] 

 

I have just written this now and it is untested but looks correct AFAICS.

Link to comment
Share on other sites

  • 2 weeks later...

hello

 

I have enabled SEO and all work well.... The generated URL look like this:

 

http://www.mysite.com/whmcs/knowledgebase/18/about-domain-name.html

 

I would like change the folder name "knowledgebase" with another term because my site are not in english...How I can do that ?

 

I have try top simply rename this term present inside htaccess file but this don't work and make error 404...

 

thank

 

cheers

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated