Jump to content

.htaccess assistance


Convergence

Recommended Posts

Greetings,

 

We have multiple WHMCS licenses - LOVE IT!

 

We are setting up a 'corporate' support portal that lists all our different website departments.

 

One of the website departments is for a website that has it's own license of WHMCS.

 

When someone clicks on that department, we want it to redirect to the WHMCS support department that is installed on that domain.

 

Example:

 

Corporate Support Portal is on website-1.com

Second WHMCS install is on website-2.com

 

Customer clicks on 'Website-2 Support Department'

WHMCS URL is:

https://www.website-1.com/clients/submitticket.php?step=2&deptid=14

 

We need it to go to the WHMCS submit ticket URL that is installed on that domain:

https://www.website-2.com/clients/submitticket.php

 

Need help in creating the .htaccess rewrite rule.

 

We have the basic .htaccess in the /clients/ directory on website-1.com

RewriteEngine On


# Announcements
RewriteRule ^announcements/([0-9]+)/[a-z0-9_-]+\.html$ ./announcements.php?id=$1 [L,NC]
RewriteRule ^announcements$ ./announcements.php [L,NC]

# Downloads
RewriteRule ^downloads/([0-9]+)/([^/]*)$ ./downloads.php?action=displaycat&catid=$1 [L,NC]
RewriteRule ^downloads$ ./downloads.php [L,NC]

# Knowledgebase
RewriteRule ^knowledgebase/([0-9]+)/[a-z0-9_-]+\.html$ ./knowledgebase.php?action=displayarticle&id=$1 [L,NC]
RewriteRule ^knowledgebase/([0-9]+)/([^/]*)$ ./knowledgebase.php?action=displaycat&catid=$1 [L,NC]
RewriteRule ^knowledgebase$ ./knowledgebase.php [L,NC]

 

Thanks!

Link to comment
Share on other sites

You could edit the template to display a link which looks similar to the standard departmental links and have it point to whatever URL you want.

 

Hi Jamroar -

 

Thanks for your response.

 

There are 10 departments on that page. Editing the template to jury-rig it is not what we really want to do and is why we are looking for .htaccess help.

 

Thanks again, for your response.

 

Anyone else have some .htaccess love to share?

Link to comment
Share on other sites

Hi Jamroar -

 

Thanks for your response.

 

There are 10 departments on that page. Editing the template to jury-rig it is not what we really want to do and is why we are looking for .htaccess help.

 

Thanks again, for your response.

 

Anyone else have some .htaccess love to share?

I don't know why you would want to have to go through the trouble of creating HTACCESS rules when you could simply add a couple of IF statements to the FOREACH within the template to change the URL to that of the other server(s) directly. To each his own I suppose, but I'd simply do the following within "supportticketsubmit-stepone.tpl":

 

FIND:

{$smarty.server.PHP_SELF}?step=2&deptid={$department.id}

 

REPLACE with:

{if $department.id eq "66"}http://hostname.tld/submitticket.php?step=2&deptid=66{else}{$smarty.server.PHP_SELF}?step=2&deptid={$department.id}{/if}

 

If you need this for more than one department, use the following REPLACE instead, adding an "elseif" for each department that requires redirection:

{if $department.id eq "66"}http://hostname.tld/submitticket.php?step=2&deptid=66{elseif $department.id eq "69"}http://hostname.tld/submitticket.php?step=2&deptid=69{else}{$smarty.server.PHP_SELF}?step=2&deptid={$department.id}{/if}

 

Quite simply, this will redirect the customer exactly as if they had clicked on the respective department within the portal of the WHMCS installation that's actually hosting it. You would, of course, need to set "deptid" in the URL(s) to that of the respective department on the remote WHMCS.

Edited by GGWH-James
Link to comment
Share on other sites

If you really wanted to get creative, you could most likey make it dynamic with a single IF statement and some PHP code which performs a regex on the departments email address field to see if it's set to an e-mail address or a URL. You would then put the complete URL of the remote WHMCS departments into the e-mail field of the local WHMCS departments.

Link to comment
Share on other sites

Why even bother with the if statements? You could just pass the {$department.id} variable directly to the new URL.

 

{foreach key=num item=department from=$departments}
<li><a href="https://www.website-2.com/clients/submitticket.php?step=2&deptid={$department.id}"><strong>{$department.name}</strong></a>{if $department.description} - {$department.description}{/if}</li>
{/foreach}

 

This of course assumes that all the department IDs line up. If they do not, then the mod_rewrite method would be better than modifying the template. That would assure that you do not have to worry about updating it when new versions come out.

Link to comment
Share on other sites

They may not be the same on both installations; that's why I didn't simply say to do that. ;) Template edits don't need to be overwritten though during update anymore than the HTACCESS file needs to be overwritten; for the most part. Either way will work though, depends how you want to go about it.

Link to comment
Share on other sites

Why even bother with the if statements? You could just pass the {$department.id} variable directly to the new URL.

 

{foreach key=num item=department from=$departments}
<li><a href="https://www.website-2.com/clients/submitticket.php?step=2&deptid={$department.id}"><strong>{$department.name}</strong></a>{if $department.description} - {$department.description}{/if}</li>
{/foreach}

 

This of course assumes that all the department IDs line up. If they do not, then the mod_rewrite method would be better than modifying the template. That would assure that you do not have to worry about updating it when new versions come out.

 

Hi laszlof,

 

Thank you for your suggestion - unfortunately the department IDs do NOT match up.

 

Appreciate your assistance!

Link to comment
Share on other sites

If you really wanted to get creative, you could most likey make it dynamic with a single IF statement and some PHP code which performs a regex on the departments email address field to see if it's set to an e-mail address or a URL. You would then put the complete URL of the remote WHMCS departments into the e-mail field of the local WHMCS departments.

 

Hi Jamroar -

 

LOL - that's beyond our skills at this time. I do like the idea, though - thanks!

 

If I understand correctly after adding the 'regex' code, we would then put the 'redirected' url in the email address field for that department, correct?

 

Thanks again for your help!

Link to comment
Share on other sites

If I understand correctly after adding the 'regex' code, we would then put the 'redirected' url in the email address field for that department, correct?

Yes, that's how it would work. You would then just put in a URL for remote departments and an e-mail for local ones; the template would automatically distinguish between the two and provide the correct URL (i.e. local or remote) for each department. This allows for a one-time file edit as opposed to having to update HTACCESS rules or multiple IF statements each time you add/change a remote department.

 

I'm a little busy at the moment, but will try to put something together for you later today for that if you like.

Edited by GGWH-James
Link to comment
Share on other sites

Yes, that's how it would work. You would then just put in a URL for remote departments and an e-mail for local ones; the template would automatically distinguish between the two and provide the correct URL (i.e. local or remote) for each department. This allows for a one-time file edit as opposed to having to update HTACCESS rules or multiple IF statements each time you add/change a remote department.

 

I'm a little busy at the moment, but will try to put something together for you later today for that if you like.

 

Thanks, Jamroar!

 

Any assistance is appreciated - please do so at YOUR convenience.

 

Thanks so much for your expertise!

Link to comment
Share on other sites

Sorry for the delay, but I've been a little busy as of late. Anyhow, I just threw this together for you; the code below will do the job for you. It's to replace the entire contents of the original portal "supportticketsubmit-stepone.tpl". I'm sure you can figure it out for any other template though; I only changed the code within the UL tags.

 

<p>{$LANG.supportticketsheader}</p>
<ul>
 {capture assign=dept}{php}
 $depts = mysql_query("
   SELECT id, name, description, email
   FROM tblticketdepartments
   WHERE hidden != 'on'
   ORDER BY `order` ASC
 ");
 while ($row = mysql_fetch_array($depts, MYSQL_ASSOC))
 {
   $out = "<li><a href=\"";
   if (preg_match("/@/", $row["email"]))
{
     $out .= $_SERVER['PHP_SELF'] . "?step=2&deptid=" . $row['id'];
}
else
{
  $out .= $row["email"];
}
$out .= "\"><strong>" . $row['name'] . "</strong></a>";
if ($row["description"])
{
  $out .= " - " . $row['description'];
}
$out .= "</li>";
echo $out;
unset($out);
 }
 mysql_free_result($depts);
 unset($row);
 {/php}{/capture}
 {$dept}
</ul>

 

It may be able to be cleaned up a bit, but does the job. Simply put a URL in place of an e-mail address when you create the support department in WHMCS. If you want the links to the other site(s) to open in a new window, just put a TARGET attribute in there at the appropriate place. If you want to do that and are uncertain as to how with the code above, just ask.

Edited by GGWH-James
Link to comment
Share on other sites

Jamroar,

 

THANK YOU VERY MUCH for taking the time to help.

 

Sorry for MY delay in responding - I'm a little behind myself.

 

We will make the changes as you have suggested and give you a status report when we're finished.

 

Thank you, again - it IS greatly appreciated!

Link to comment
Share on other sites

  • 2 weeks 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