GithubHelp home page GithubHelp logo

rasolofonirina / www-to-non-www-or-non-www-to-www Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 2 KB

Redirect www to non-www or non-www to www

License: MIT License

htaccess www non-www sans-www redirection redirect http https

www-to-non-www-or-non-www-to-www's Introduction

Redirect www to non-www or non-www to www

EN : If for some reason you need to redirect the www version of your website to the non-www version or the non-www version to the www version, you can use these instructions on the .htaccess file.

FR : Si pour une raison ou une autre vous avez besoin de rediriger la version www de votre site web vers la version sans www ou la version sans www vers la version www, vous pouvez utiliser ces instructions sur le fichier .htaccess.

With HTTP (avec HTTP)

# Redirect non-www to www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
# Redirect www to non-www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

With HTTPS (avec HTTPS)

EN : If the SSL certificate is installed and activated on the hosting and you want to have HTTPS.

FR : Si le certificat SSL est installé et activé sur l'hébergement et que vous souhaitez avoir HTTPS.

# Redirect non-www to www with HTTPS
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
# Redirect www to non-www with HTTPS
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTP_HOST} ^www.example\.com [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]


You can buy me a coffee here.

www-to-non-www-or-non-www-to-www's People

Contributors

rasolofonirina avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.