Jump to content

Force Language / URL rewriting tip


Recommended Posts

For those of you who like me are a bit SEO fanatic here are a few small rewrite rules for WHMCS that allow you to use language folders for separating your different language sites allowing spiders to index all of your content in all languages.

 

These rules basically append language=[langname] to all URLs based on the language sub-folder making sure that all pages can be indexed by the spiders.

 

Don't forget to change language=English to the language you want to force (e.g. language=French or language=German etc)

 

Two examples below

 


#English
RewriteRule ^en/(.*).php?(.*)#(.*) /whmcs/$1.php?$2&language=English#$3 [NC,LP,QSA] 
RewriteRule ^en/(.*).php?(.*) /whmcs/$1.php?$2&language=English [NC,LP,QSA] 
RewriteRule ^en/(.*)#(.*) /whmcs/$1?language=English#$2 [NC,LP,QSA] 
RewriteRule ^en/(.*) /whmcs/$1?language=English [NC,LP,QSA] 

#italiano

RewriteRule ^it/(.*).php?(.*)#(.*) /whmcs/$1.php?$2&language=Italian#$3 [NC,LP,QSA] 
RewriteRule ^it/(.*)?(.*) /whmcs/$1?$2&language=Italian [NC,LP,QSA] 
RewriteRule ^it/(.*)#(.*) /whmcs/$1?language=Italian#$2 [NC,LP,QSA]
RewriteRule ^it/(.*) /whmcs/$1?language=Italian [NC,LP,QSA]


 

Maybe this can be put into the tips and tricks forum, I don't seem to have access to post to there though.

Link to comment
Share on other sites

-- Update 2 --

 

Instead of the above action an easy way is to add the following code to the top of your header.tpl

 

(replace "whmcs" with your own folder where you have installed whmcs.)

 


{php}
$path  = $_SERVER['REQUEST_URI'];
$urlarray = explode("/", $path);
$_SERVER['PHP_SELF']=str_replace("whmcs",$urlarray[1],$_SERVER['PHP_SELF']);
{/php}

 

Incidentally, this only works if you have your whmcs installed in a sub-folder of root.

 

If you have it installed in the root then use the following script instead (Untested)

 


{php}
$path  = $_SERVER['REQUEST_URI'];
$urlarray = explode("/", $path);
$_SERVER['PHP_SELF'] = "/" . $urlarray[1] . $_SERVER['PHP_SELF'];
{/php}

Link to comment
Share on other sites

  • 1 year later...
  • 3 months later...
ServeWise or anyone in this forum figured out a way for mod rewrite rules to work with products and services?

As it is now no matter what product page you're on title page is identical on all. Needless to say this is a disaster for SEO

Thanks

 

I don't quite understand your question. Can you please elaborate it?

Link to comment
Share on other sites

  • 2 months later...
  • 2 weeks later...
ServeWise or anyone in this forum figured out a way for mod rewrite rules to work with products and services?

As it is now no matter what product page you're on title page is identical on all. Needless to say this is a disaster for SEO

Thanks

 

Yeah, you'll be hitting duplicate content issues here. The title tags do need to be unique...

Link to comment
Share on other sites

  • 6 years later...

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