We talking about Cloud
Web Hosting & Cloud Services
Celebrate the power and freedom of Open Source
with Open Source Cloud Servers starting at only £10/mo £5/mo.
Web Hosting & Cloud Services
Celebrate the power and freedom of Open Source
with Open Source Cloud Servers starting at only £10/mo £5/mo.
HostGator uses Apache, the open source HTTP server software, to host your website. Apache can be customized via modules, and the mod_rewrite module is available for you to use yourself. mod_rewrite can redirect one URL to another URL, rewrite requested URLs, limit access to your site and much more.
A rewrite rule can be invoked by placing it in your .htaccess file. Below are examples of how you can use these rules to customize your hosting experience.
Here are examples of rules that allow you to do the following:
#Specify a default home page (index page) DirectoryIndex home.html
#Allow only specified IPs to access your site deny from all allow from 64.95.219.140 allow from 210.23.45.67
# Redirect all pages from olddomain.com # to newdomain.com Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^www.olddomain.com$ [OR] RewriteCond %{HTTP_HOST} ^olddomain.com$ RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
#Prevent subfolder loading. This goes # in htaccess for the primary domain RewriteCond %{HTTP_HOST} ^primary.com$ [OR] RewriteCond %{HTTP_HOST} ^www.primary.com$ RewriteRule ^addon.com/?(.*)$ "http://www.addon.com/$1" [R=301,L]
#Prevent subdomain name loading. #This goes in htaccess for the primary domain RewriteCond %{HTTP_HOST} ^subname.primary.com$ [OR] RewriteCond %{HTTP_HOST} ^www.subname.primary.com$ RewriteRule ^(.*)$ "http://www.addon.com/$1" [R=301,L]
# Never use www in the domain # Replace 'example.com' with your domain name RewriteEngine on RewriteCond %{HTTP_HOST} ^www.(([a-z0-9_]+.)?example.com)$ [NC] RewriteRule .? http://%1%{REQUEST_URI} [R=301,L]
# Always use www in the domain # Replace 'example.com' with your domain name RewriteEngine on RewriteCond %{HTTP_HOST} ^([a-z.]+)?example.com$ [NC] RewriteCond %{HTTP_HOST} !^www. [NC] RewriteRule .? http://www.%1example.com%{REQUEST_URI} [R=301,L]
# Set a default home directory, (this subfolder always loads) # Replace 'folder' with your subfolder name <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^$ /folder/ [R=301,L] </IfModule>
# Rename a directory and force visitors to the new name # Replace 'old' with your old folder name # Replace 'new' with your new folder name RewriteEngine on RewriteRule ^/?old([a-z/.]*)$ /new$1 [R=301,L]
# Always use https for secure connections # Replace 'www.example.com' with your domain name # (as it appears on your SSL certificate) RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
# Block traffic from multiple referrers RewriteEngine on Options +FollowSymlinks RewriteCond %{HTTP_REFERER} badsite.com [NC,OR] RewriteCond %{HTTP_REFERER} badforum.com [NC,OR] RewriteCond %{HTTP_REFERER} badsearchengine.com [NC] RewriteRule .* - [F]
#Do not allow these file types to be called RewriteEngine on RewriteRule .*.(jpg|jpeg|gif|png|bmp|exe|swf)$ - [F,NC]
Options +FollowSymLinks -MultiViews -indexes RewriteEngine On RewriteBase / # remove index RewriteCond %{THE_REQUEST} /index(.php)?[s?/] [NC] RewriteRule ^(.*?)index(/|$) /$1 [L,R=301,NC,NE]
Options +FollowSymLinks -MultiViews -indexes RewriteEngine On RewriteBase / # remove .php; use THE_REQUEST to prevent infinite loops RewriteCond %{THE_REQUEST} ^GET (.*).php HTTP RewriteRule (.*).php$ $1 [L,R=301]
Options +FollowSymLinks -MultiViews -indexes RewriteEngine On RewriteBase / # remove index RewriteRule (.*)/index$ $1/ [R=302] # remove slash if not directory RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} /$ RewriteRule (.*)/ $1 [R=301,L]
Options +FollowSymLinks -MultiViews -indexes RewriteEngine On RewriteBase / # add .php to access file, but don't redirect RewriteCond %{REQUEST_FILENAME}.php -f RewriteCond %{REQUEST_URI} !/$ RewriteRule (.*) $1.php [L]
The following articles are for reference only. Please note that HostGator cannot offer direct support for the information provided below.
This site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.
OKLearn moreWe may request cookies to be set on your device. We use cookies to let us know when you visit our websites, how you interact with us, to enrich your user experience, and to customize your relationship with our website.
Click on the different category headings to find out more. You can also change some of your preferences. Note that blocking some types of cookies may impact your experience on our websites and the services we are able to offer.
These cookies are strictly necessary to provide you with services available through our website and to use some of its features.
Because these cookies are strictly necessary to deliver the website, refusing them will have impact how our site functions. You always can block or delete cookies by changing your browser settings and force blocking all cookies on this website. But this will always prompt you to accept/refuse cookies when revisiting our site.
We fully respect if you want to refuse cookies but to avoid asking you again and again kindly allow us to store a cookie for that. You are free to opt out any time or opt in for other cookies to get a better experience. If you refuse cookies we will remove all set cookies in our domain.
We provide you with a list of stored cookies on your computer in our domain so you can check what we stored. Due to security reasons we are not able to show or modify cookies from other domains. You can check these in your browser security settings.
These cookies collect information that is used either in aggregate form to help us understand how our website is being used or how effective our marketing campaigns are, or to help us customize our website and application for you in order to enhance your experience.
If you do not want that we track your visit to our site you can disable tracking in your browser here:
We also use different external services like Google Webfonts, Google Maps, and external Video providers. Since these providers may collect personal data like your IP address we allow you to block them here. Please be aware that this might heavily reduce the functionality and appearance of our site. Changes will take effect once you reload the page.
Google Webfont Settings:
Google Map Settings:
Google reCaptcha Settings:
Vimeo and Youtube video embeds:
The following cookies are also needed - You can choose if you want to allow them:
You can read about our cookies and privacy settings in detail on our Privacy Policy Page.
Privacy Policy