Difference between revisions of "Friendly URLs"

From WHMCS Documentation

 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<div class="docs-alert-info"><i class="fa fa-question-circle"></i> This page describes a feature available in version 7.2 and above</div>
+
<div class="docs-alert-info"><i class="fa fa-question-circle"></i> We added this feature in WHMCS 7.2.</div>
  
 
Many parts of WHMCS can be accessed through search-engine-friendly URLs. The way in which WHMCS processes these depends on your server environment.  
 
Many parts of WHMCS can be accessed through search-engine-friendly URLs. The way in which WHMCS processes these depends on your server environment.  
Line 5: Line 5:
 
== What is a Friendly URL? ==
 
== What is a Friendly URL? ==
  
When you use Search Engine [[Friendly_URLs|Friendly URLs]], for example, a URL that looks like this:
+
By default, URLs in WHMCS use the following format:
 
   
 
   
 
<div class="source-cli">/knowledgebase.php?action=view&id=1</div>
 
<div class="source-cli">/knowledgebase.php?action=view&id=1</div>
 
   
 
   
becomes
+
However, when you enable Search Engine Friendly URLs, they use this format:
 
   
 
   
 
<div class="source-cli">/knowledgebase/1/How_do_I_access_my_control_panel.html</div>
 
<div class="source-cli">/knowledgebase/1/How_do_I_access_my_control_panel.html</div>
 
   
 
   
You can enable these for the MarketConnect landing pages, announcements, downloads, and knowledgebase sections of the WHMCS Client Area.
+
You can enable these for MarketConnect landing pages, announcements, downloads, and the knowledgebase sections of the WHMCS Client Area.
  
 
==Product and Product Group Friendly URLs==
 
==Product and Product Group Friendly URLs==
Line 19: Line 19:
 
<div class="docs-alert-info"> We added product group URLs in WHMCS 8.0 and product URLs in WHMCS 8.3.</div>
 
<div class="docs-alert-info"> We added product group URLs in WHMCS 8.0 and product URLs in WHMCS 8.3.</div>
  
When you click '''Edit''' for a product group or product at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > [[Products and Services|Products/Services]]''' or, prior to WHMCS 8.0, '''Setup > Products/Services > Products/Services''' displays a link for the group or various links for the product. You can use these links to direct clients to a specific page or to load the product into their cart and immediately take them to the configuration step for that product.
+
When you click '''Edit''' for a product group or product at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > [[Products and Services|Products/Services]]''' or, prior to WHMCS 8.0, '''Setup > Products/Services > Products/Services''', the system displays a link for the group or various links for the product. You can use these links to direct clients to a specific page or to load the product into their cart and immediately take them to the configuration step for that product.
  
 
[[File:link-tab-urls-83.png|thumb|]]
 
[[File:link-tab-urls-83.png|thumb|]]
Line 29: Line 29:
 
<div class="docs-alert-info"> We added these features in WHMCS 7.2.</div>
 
<div class="docs-alert-info"> We added these features in WHMCS 7.2.</div>
  
The settings that affect WHMCS's behavior regarding other friendly URLs are in the '''[[General Tab|General]]''' tab at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > General Settings''' or, prior to WHMCS 8.0, '''Setup > General Settings'''.
+
You can use the settings in the '''[[General Tab|General]]''' tab at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > General Settings''' or, prior to WHMCS 8.0, '''Setup > General Settings''' to configure the following behavior:
  
[[File:friendly_uri_setting.png|700px]]
+
* WHMCS's behavior for other friendly URLs.
 +
* The mode that WHMCS uses.
  
=== Enabling Friendly URLs ===
+
WHMCS uses the URI path mode when it constructs URIs, URLs, or relative paths in rendered output (for example, links on pages).
 
 
For Apache environments, to enable this:
 
 
 
# Go to '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > General Settings''' or, prior to WHMCS 8.0, '''Setup > General Settings'''.
 
# Choose the '''[[General Tab|General]]''' tab.
 
# Set '''Friendly URLs''' to ''Full Friendly Rewrite''.
 
# Click '''Save Changes'''.
 
 
 
For IIS environments, you must check whether the URL rewrite module [http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/ is installed for IIS]. Then, set up the rewrite rules as follows:
 
 
 
# Open IIS Manager.
 
# Browse to the site you want to add the rule to.
 
# In the right pane, double-click and select ''urlrewrite''.
 
# On the right side inbound rules, select ''import rules''.
 
# Extract the mod_rewrite rules from the WHMCS's rewrite file at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > General Settings''' or, prior to WHMCS 8.0, '''Setup > General Settings''', in the '''Advanced Settings''' section.
 
# Paste those rules into the ''rewrite rules'' field.
 
# Click '''Apply'''.
 
 
 
===Simple Mode Selection===
 
 
 
In the '''[[General Tab|General]]''' tab at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > General Settings''' or, prior to WHMCS 8.0, '''Setup > General Settings''', two controls simplify the SEF mode that WHMCS will use.
 
  
 
[[File:friendly_uri_setting.png|700px]]
 
[[File:friendly_uri_setting.png|700px]]
  
WHMCS uses the URI path mode when it constructs URIs, URLs, or relative paths in rendered output (for example, links on pages).
+
For more information about each setting, help for selecting your configuration, and examples of related <tt>.htaccess</tt> rules, see [[General_Tab#WHMCS_Rules|General Tab]].
 
 
You can choose the following URI path modes:
 
 
 
* '''Full Friendly Rewrite''' — This option will generate highly systematic URLs, which are excellent for search engines and visitors alike.  They are completely decoupled from the file system. 
 
** This mode is only valid in environments that support Apache Mod_Rewrite behavior. 
 
** For example: <tt><nowiki>http://example.com/knowledgebase</nowiki></tt>
 
* '''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. 
 
** For example: <tt><nowiki>http://example.com/index.php/knowledgebase</nowiki></tt>
 
* '''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.
 
** For example: <tt><nowiki>http://example.com/index.php?rp=/knowledgebase</nowiki></tt>
 
 
 
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.
 
  
 
[[File:Friendly_Url_Simple_Mode_Select.png|280px]]
 
[[File:Friendly_Url_Simple_Mode_Select.png|280px]]
  
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.
+
<div class="docs-alert-info"> WHMCS is unable to detect the most viable '''Friendly URL''' setting for your installation when you have enabled '''Maintenance Mode''' because the system defaults to ''Basic URLs''.</div>
  
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".
+
=== Upgrading to WHMCS 7.2 ===
 
 
=Advanced Settings=
 
 
 
'''Advanced Settings''' provides you more options and information so that you may manually optimizing your environment and WHMCS settings for Friendly URLs.
 
 
 
* The '''Path Mode''' tab allows you to manually override the system-detected URI path mode and shows which modes are supported by your environment.
 
* The '''Rewrite File''' tab 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 Initial Evaluation ===
 
  
 
Upon installation (or upgrade to v7.2), WHMCS will perform an evaluation of your current environment.  This evaluation will inspect the following:
 
Upon installation (or upgrade to v7.2), WHMCS will perform an evaluation of your current environment.  This evaluation will inspect the following:
Line 107: Line 65:
  
 
* 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.
 
* 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.
 
====Manual Management====
 
 
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.
 
 
<div class="docs-alert-info">&nbsp; Compatibility with other rules in .htaccess will need to be determined and adjusted by your system administrative staff.  WHMCS cannot automatically detect compatibility with other rules. Furthermore, WHMCS Technical Support can only provided limited suggestions based on what WHMCS required to function as designed.
 
</div>
 
 
===WHMCS Rules===
 
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.
 
 
<div class="docs-alert-info"><i class="fa fa-question-circle"></i> These .htaccess rules apply to WHMCS version 7.2 and above.</div>
 
<pre>
 
### BEGIN - WHMCS managed rules - DO NOT EDIT BETWEEN WHMCS MARKERS ###
 
<IfModule mod_rewrite.c>
 
RewriteEngine on
 
 
# RewriteBase is set to "/" so rules do not need updating if the
 
# installation directory is relocated.  It is imperative that
 
# there is also a RewriteCond rule later that can effectively get
 
# the actual value by comparison against the request URI.
 
#
 
# If there are _any_ other RewriteBase directives in this file,
 
# the last entry will take precedence!
 
RewriteBase /
 
 
# Redirect directories to an address with slash
 
RewriteCond %{REQUEST_FILENAME} -d
 
RewriteRule ^(.+[^/])$  $1/ [R]
 
 
# Send all remaining (routable paths) through index.php
 
RewriteCond %{REQUEST_FILENAME} !-f
 
RewriteCond %{REQUEST_FILENAME} !-d
 
# Determine and use the actual base
 
RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$
 
RewriteRule ^.*$ %2index.php [QSA,L]
 
</IfModule>
 
### END - WHMCS managed rules - DO NOT EDIT BETWEEN WHMCS MARKERS ###
 
</pre>
 

Latest revision as of 17:19, 25 January 2023

We added this feature in WHMCS 7.2.

Many parts of WHMCS can be accessed through search-engine-friendly URLs. The way in which WHMCS processes these depends on your server environment.

What is a Friendly URL?

By default, URLs in WHMCS use the following format:

/knowledgebase.php?action=view&id=1

However, when you enable Search Engine Friendly URLs, they use this format:

/knowledgebase/1/How_do_I_access_my_control_panel.html

You can enable these for MarketConnect landing pages, announcements, downloads, and the knowledgebase sections of the WHMCS Client Area.

Product and Product Group Friendly URLs

We added product group URLs in WHMCS 8.0 and product URLs in WHMCS 8.3.

When you click Edit for a product group or product at Configuration () > System Settings > Products/Services or, prior to WHMCS 8.0, Setup > Products/Services > Products/Services, the system displays a link for the group or various links for the product. You can use these links to direct clients to a specific page or to load the product into their cart and immediately take them to the configuration step for that product.

Link-tab-urls-83.png

For more information, see Linking to WHMCS.

Other Friendly URLs

We added these features in WHMCS 7.2.

You can use the settings in the General tab at Configuration () > System Settings > General Settings or, prior to WHMCS 8.0, Setup > General Settings to configure the following behavior:

  • WHMCS's behavior for other friendly URLs.
  • The mode that WHMCS uses.

WHMCS uses the URI path mode when it constructs URIs, URLs, or relative paths in rendered output (for example, links on pages).

Friendly uri setting.png

For more information about each setting, help for selecting your configuration, and examples of related .htaccess rules, see General Tab.

Friendly Url Simple Mode Select.png

WHMCS is unable to detect the most viable Friendly URL setting for your installation when you have enabled Maintenance Mode because the system defaults to Basic URLs.

Upgrading to WHMCS 7.2

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.