Skip to main content
Help Center
The GoDaddy Community will undergo maintenance starting on Wednesday, August 4th at 3pm PST / 6pm EST. Learn more
  • GoDaddy Community
  • GoDaddy Website Builders
  • GoDaddy Website Builders

    cancel
    Showing results for 
    Show  only  | Search instead for 
    Did you mean: 
    ixikhalil
    New

    Redirecting from example.com to www.example.com

    I'm trying to create a redirection from my example.com website to the www.example.com version , but when I do it , it show's me an error that there is a loop in my domains , What to do ?

    4 REPLIES 4
    JMPepper
    Advocate VII

    Hi @ixikhalil,

     

    Here's a rewrite rule for your htaccess file.

     

    # 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]

     

    Hope this helps,

    James

    Not Just Pretty Sites, Pretty Doggone Smart Sites

    Here is my problem with the details So pleeease help me , because I'm not experienced in things like that.

    I have installed the Laravel 5.2 in my Linux Server And I made it so hardly by modifying the HTACCESS file , So now I'm trying to make a redirection from the www to the non-www version I mean like stackoverflow from www.example.com >>TO>> example.com , But I'm afraid because I may crash my server so please help :

    RewriteEngine on 
    
    # I changed my website real name to example
    RewriteCond %{HTTP_HOST} ^(www.)?example.com$ 
    
    RewriteCond %{REQUEST_URI} !^/example/ 
    
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /example/$1
    RewriteCond %{HTTP_HOST} ^(www.)?example.com$
    RewriteRule ^(/)?$ example/index.php [L]

    Thanks in advance

     

    In the code below every time you see the word example replace it with your domain name.  Note that when you do this, you'll see the logic of the rewrite for your site.  If you are still uncomfortable with changing it yourself, call tech support and email them the info.  They will check it and make sure its right and insert it into your file for your.

     

    Hope this helps,

    James

    Not Just Pretty Sites, Pretty Doggone Smart Sites
    Raylistar
    New

    @JMPepper,

    I've implemented the following code, as prescribed by GoDaddy for my CPanel account, in order to convert http visits to a secure URL (https). But it also converts my add-on domain, which I do NOT want. (It would require an additional or more expensive certificate.) How do I modify the .htacess code in order to have it work only on my main domain, not add-on domains?  I've checked various articles online, but the RewriteEngine/Regular Expression syntax is a bit beyond my understanding.

    https://www.godaddy.com/help/redirect-http-to-https-automatically-8828
    Redirect HTTP to HTTPS automatically (Apache/Linux/CPanel)

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]