An .htaccess file is used to modify the default configuration of a web server for a website. This can be used for redirecting website traffic, forcing traffic to secure pages, and so much more. While we cannot go over everything an .htaccess file can do, we will touch on the most common uses.
Sections
- What is an .htaccess file
- Redirecting to a different website
- Altering your home (index) page
- Redirecting to HTTPS
- Directing users to your CMS software
What is an .htaccess file
An .htaccess file is a type of configuration file that can be used by various web servers to control different aspects of website access, such as redirecting or shortening URLs, restricting access to certain web pages or files, and more. An .htaccess file is located in a specific document directory and affects that directory and all its subdirectories. An .htaccess file can contain one or more directives, which are commands that tell the web server how to handle requests for the directory or its contents.
The most common uses of .htaccess files are:
- redirecting web site traffic
- altering the site home (index) page
- directing HTTP traffic to HTTPS
- directing users to CMS software
You can edit your .htaccess file using any plain text editor.
Redirecting to a different website
You can use the .htaccess file to redirect traffic to your website to another site. This can be for the entire site or only one page. Here are a few examples:
Redirect an entire site
Redirect 301 / https://www.domain.com/
Redirect an entire site to a sub folder
Redirect 301 / https://www.domain.com/subfolder/
Redirect a sub folder to another site
Redirect 301 /subfolder https://www.domain.com/
Redirect a single page
Redirect 301 /pagename.php https://www.domain.com/pagename.html
Redirect to a different extension
This will redirect any file with the .html extension to use the same filename but use the .php extension instead.
RedirectMatch 301 (.*)\.html$ https://www.domain.com$1.php
Altering your home (index) page
If your site does not use a standard index file, you can use the .htaccess file to force browsers to load the correct file.
# Change default website page
DirectoryIndex home.php
Redirecting to HTTPS
Another common use of the .htaccess file is to redirect all HTTP traffic to the secure, SSL protected version of your site.
# Redirect to HTTPS
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^(.*)$ https://www.domain.com/$1 [R,L]
Directing users to your CMS software
Most CMS software includes its own .htaccess file to load and manage your website content. If your page is not loading correctly, it is possible that your .htaccess file have been removed or altered. If this is the case, you can contact your CMS support for a new .htaccess file. These are typically generic and do not contain any information specific to your site.
Still Having Issues?
If you are still having issues, you can contact our Customer Support in the following methods:
Live Chat
You can connect to our Live Chat Support Team from your MacHighway Client Area. If you are not sure how to do this, you can find a guide here.
Our Live Chat team is available Monday to Friday from 9:00 AM to 7:00 PM Eastern Time.
Support Ticket
You can submit a support ticket to our Support Team from your client area.
Our ticket Support Team is available 24/7/365.
Phone support
You can contact our Phone Support Team using the following number:
- US/Canada 1-888-974-0334
- International 1-727-800-3606
Our Phone Support team is available Monday to Friday from 9:00 AM to 7:00 PM Eastern Time.