Many functions and pages of WHMCS can be accessed through search engine friendly (SEF) URLs. The capability of WHMCS to process such URIs is heavily dependent on the webserver environment. WHMCS will perform an initial inspection of the environment and automatically configure the most optimal settings for your environment.
There are several settings that will affect the WHMCS's behavior regarding SEF. They are located in the Setup > General Settings > General Tab.
Simple Mode Selection
Directly in the General Tab, next the the Friendly URLs label are two controls that can simplify the SEF mode that WHMCS will use.
URI Path Mode
The URI path mode is used by WHMCS when constructing URIs, URLs, or relative paths in rendered output (ie. links on pages).
There are three possible modes:
- Fully Friendly Rewrite - This option will generate highly systematic URLs, which are excellent for search engines and visitors alike. The are completely decoupled from the file system. This mode is only valid in environments that support Apache Mod_Rewrite behavior.
- Example: http://awesome.host/knowledgebase
- Friendly index.php - This option will generate systematic URLs but is coupled to the filesystem. It is a good option for search engines and visitors if your environment does not support Apache Mod_Rewrite. This mode is only valid in environments that support Apache AcceptPathInfo behavior.
- Example: http://awesome.host/index.php/knowledgebase
- Basic URLs - This option will generate URLs which are ubiquitously supported in all web environments. Most search engine technologies are capable of moderate to advanced indexing when analyzing these types of URLs. However some internet users find these URLs unattractive and cumbersome.
- Example: http://awesome.host/index.php?rp=/knowledgebase
You can quickly change the URI path mode via the dynamic dropdown which lists all possible URI path mode options. Your current mode setting will appear with a white background at the top of dynamic dropdown selection, as well as in the options list within a right-angle bracket denoting the selection.
The best option detected by WHMCS for your current environment will have a green background within options list. All other options will have a blue background. You may select and override the system's best detected suggestion at any time to facilitate the optimal experience for you WHMCS. One such scenario would be if you WHMCS is running on a web server other than Apache, where URL rewrites are controlled at a server-level and cannot be accurately observed by applications. Another scenario might be if a customization prepares link paths relative to the current link path and not as absolute path to WHMCS or the website.
When you select an option from the dynamic dropdown it will be saved automatically. The current selection denotation will be updated as well as the status label. If the selection is the same as what was detected as the best option, the status label will be green and read "System-Detected", otherwise it will be blue and read "Manual-Override".
The recheck button, represented with a circular arrow icon, will perform an environment detection and immediately update your Friendly URLs settings to the optimal configuration. If the Auto-Managed Rewrite setting is not enabled, and the system detects that modifications to your rewrite file (.htaccess) may occur during the optimization routine, you will be a prompted to enable it before any changes are applied.
To the right of the URI Mode Selection and Recheck Button the is an Advanced Setting link which provides you more options and information so that you may manually optimizing your environment and WHMCS settings for Friendly URLs.
The Path Mode management tab of Advanced Settings allows you to manually override the system-detected URI Path Mode and shows which modes are known to be support by your environment.
The settings provided here perform the same result as the Simple Mode Selection but with more explicit control. Notably, you may enable the manual override option while selecting a URI Path Mode that is the same as the system detected value.
Setting are automatically saved on change.
The Rewrite File management tab of Advanced Settings allows you to manually select how WHMCS should control the rewrite file (.htaccess) as well as a copy of the WHMCS rewrite rules. Rewrite rules are used to alter inbound HTTP requests so that the application can effectively process Friendly URLs
Rewrite File Management
Upon installation (or upgrade to v7.2), WHMCS will perform an evaluation of your current environment. This evaluation will inspect the following:
A. Does the current environment support Apache Mod_Rewrite?
B. Is there an .htaccess file within the WHMCS root directory?
C. If there is an .htaccess file, are the contents identical to the suggested ruleset provided in htaccess.txt of previous WHMCS releases?
D. If there is an .htaccess file, and it is not identical to previous releases' ruleset suggestions, do the contents contain the WHMCS comment marks indicating WHMCS has leveraged this file in the past?
After the evaluation, one of the following will occur:
- If the current environment is not supported (not A), then Auto-Managed Rewrite is disabled and and no further action will be taken.
- If the environment is supported (A) and a .htaccess file does exist (not B), Auto-Managed Rewrite will be enabled and a fresh .htaccess file will be created with the latest WHMCS rewrite ruleset. Any future update of WHMCS that requires a change to the rewrite ruleset will be applied automatically during the update process.
- If the environment is supported (A) and there is an .htaccess file (B), only if the contents are solely WHMCS content (C) or the WHMCS ruleset has been managed by WHMCS automation along with your own custom rules (D) will Auto-Managed Rewrite be enabled. The current .htaccess file will be updated to the current WHMCS ruleset. Any future update of WHMCS that requires a change to the rewrite ruleset will be applied automatically during the update process.
- If the environment is supported (A) and there is a .htaccess file (B), but it is not solely WHMCS content or there is no indication that WHMCS can manage its rules along side your custom rules (neither C or D), then Auto-Managed Rewrite is disabled and no further action will be taken.
At any time you may enable or disable Auto-Managed Rewrite. When this option is enabled, any new rules issued as part of a WHMCS update will be applied to the .htaccess file of the WHMCS root directory during the update process. Your Auto-Managed Rewrite toggle selection is immediately saved on change.
Manually enabling Auto-Managed Rewrite will not automatically reevaluate or synchronize the WHMCS ruleset. Likewise, disabling Auto-Managed Rewrite will not inspect or alter the contents of .htaccess.
When the Advanced Setting dialog is opened, if the current contents of .htaccess are not in-sync with the WHMCS ruleset, you will have a Synchronize option. This option is provided regardless of the Auto-Managed Rewrite setting. To synchronize the ruleset, simply click the Synchronize button that is below the Auto-Managed Rewrite toggle. Synchronization will occur immediately when this button is clicked.
When rules are applied to .htaccess, they are placed between comment markers that clearly indicate the beginning and end of the WHMCS ruleset. If you require custom rulesets for other destinations within the WHMCS root directory, make sure that you place them before or after these comment markers.
A copy of the WHMCS ruleset for your current version of WHMCS is displayed for your inspection and application. Some web environments provide alternative mechanisms for performing URI rewrites on inbound HTTP requests. Your system administrative staff should be able to update your alternative web environment based on this information to fully utilize the Friendly URLs feature of WHMCS.