Showing posts with label Redirect. Show all posts
Showing posts with label Redirect. Show all posts

Thursday 11 October 2018

How to redirect www to non www AND http to https in AWS .htaccess


AWS WWW to non WWW redirection
RewriteEngine On
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^.*$ https://example.com%{REQUEST_URI}
AWS HTTP to HTTPS redirection
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^.*$ https://example.com%{REQUEST_URI}
AWS WWW to non WWW and HTTP to HTTPS
RewriteEngine On
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^.*$ https://example.com%{REQUEST_URI}
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^.*$ https://example.com%{REQUEST_URI}

Tuesday 29 May 2018

How to force redirect HTTP to HTTPS in AWS or any other server using .htaccess

1st Method
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule .* https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]

RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

2nd Method
<IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteCond %{HTTPS} !on
     RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

Thursday 27 August 2015

Redirect all urls exactly, just change domain name

How to change domain using htaccess file

Many times we have a in CMS and Ecommerce website to change the domain due to maintenance or other reason but the main headache is the suburl (categories or collection) should be work as it is other wise we need to write the 301 url redirect for each and every url to not get the SEO errors.
This is tutorial will be help for the following CMS :
  1. wordpress development
  2. Joomal development
  3. Drupal development
There are Ecommerce platform that get help from this
  1. Magento development
  2. Opencart development
  3. Woocommerce
  4. Virtumart
So here is the simple and easy option that will work using the add the few lines in the htaccess file (if file not available create it .htaccess).


RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:www\.)domain\.com$ [NC]
RewriteRule ^ http://newdomain.com%{REQUEST_URI} [L,R=301]