The htaccess file is an important configuration file that sits in the root directory of your Joomla Instance. The htaccess file can be used to override certain server configuration settings or provide or block access to the site or directories. It even has useful URL rewriting capabilities. Below you fill find common uses for the htaccess file.
IMPORTANT: Making modifications to the htaccess file can potentially disable or break your Joomla Instance. The CloudAccess.net Support Team does not provide troubleshooting outside of what is listed below.
To www or not www, that is the question
You may find that your Joomla Instance is indexed by search engines as both www.yourdomain.com and yourdomain.com. It is a good idea to stay consistent with your branding and force all traffic through either one or the other. These rules can be placed anywhere below Mod-Rewrite section of your htaccess file.
Redirect to www
RewriteCond %{HTTP_HOST} ^yourdomain\.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^yourdomain\.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
Redirect to non-www
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Forcing https with SSL
When setting up an SSL, you will have the ability to route traffic through a secure port 443. This is usually done by forcing https within the Joomla Global Configuration settings. You can also force all or certain pages to https from within the htaccess file. To do so, place the following code below Mod_Rewrite
When setting up an SSL, you will have the ability to route traffic through a secure port 443. This is usually done by forcing https within the Joomla Global Configuration settings. You can also force all or certain pages to https from within the htaccess file. To do so, place the following code below Mod_Rewrite
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}>
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}>
Create Vanity URL
You may find that an architected URL is needed in certain cases. While we recommend using core-Joomla to generate your URLs, it is not always possible to do so appropriately. For example, if you have a promotional offer that requires a shortend URL, you may decide to redirect www.yourdomain.com/promo123 to a specific article. Add this rule after the Mod-Rewrite
You may find that an architected URL is needed in certain cases. While we recommend using core-Joomla to generate your URLs, it is not always possible to do so appropriately. For example, if you have a promotional offer that requires a shortend URL, you may decide to redirect www.yourdomain.com/promo123 to a specific article. Add this rule after the Mod-Rewrite
RewriteRule ^promo123 /full-path/to-desired/page.html [R=301,L]
Whitelist IP addresses
In some cases, you may find it beneficial to block your instance from the world and only allow a handful of IP addresses to view either the front end or back end only. To do this, utilize the “allow from” rule. IMPORTANT: blocking access may reduce the ability for CloudAccess.net to support your Joomla Instance. Contact us for a list of support IP addresses. To implement this rule, place it at the very beginning of your htaccess file.
In some cases, you may find it beneficial to block your instance from the world and only allow a handful of IP addresses to view either the front end or back end only. To do this, utilize the “allow from” rule. IMPORTANT: blocking access may reduce the ability for CloudAccess.net to support your Joomla Instance. Contact us for a list of support IP addresses. To implement this rule, place it at the very beginning of your htaccess file.
Blacklist IP addresses
Similar to limiting access by allowing only certain IP addresses, you also have the ability to block access by IP addresses. This is done by using the “deny from” rule, and can be set to block specific IP addresses or entire IP address ranges. To implement this rule, place it at the very beginning of your htaccess file.
Similar to limiting access by allowing only certain IP addresses, you also have the ability to block access by IP addresses. This is done by using the “deny from” rule, and can be set to block specific IP addresses or entire IP address ranges. To implement this rule, place it at the very beginning of your htaccess file.
Order allow,Deny
Deny from 111.22.3.4
Deny from 111.22.3.
Allow from all
Deny from 111.22.3.4
Deny from 111.22.3.
Allow from all
301 Redirect all non-primary URL's to primary URL
In some cases when using the CloudAccess.net Alias Tool in the Cloud Control Panel, you will find that it is necessary to go a step further to provide proper 301 redirect. Here is the rule that should be placed in teh site to ensure this 301 redirect happens
In some cases when using the CloudAccess.net Alias Tool in the Cloud Control Panel, you will find that it is necessary to go a step further to provide proper 301 redirect. Here is the rule that should be placed in teh site to ensure this 301 redirect happens
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteCond %{REQUEST_URI} !administrator
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://www.domain.com/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !administrator
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://www.domain.com/$1 [R=301,L]
No comments:
Post a Comment