url-redirection


Redirection With https from www to non-www


I have very simple requirement, I want a set of RewriteRule which can do the following things
Redirect all www request to non-www.
Redirect all request to https.
Ultimately my URL requirement is like http://domain.com
I am able to do most things but a request like https://www.domain.com is not redirecting.
This my redirection rule:
RewriteCond %{HTTP_HOST} ^www.domain.com [NC]
RewriteRule ^(.*) http://domain.com/$1 [L,R=301]
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Please suggest what I need to do.
Use this code below
RewriteEngine On
#Redirect HTTP with www to HTTPS without www
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule .* https://%1%{REQUEST_URI} [R=301,L]
# Redirect HTTP without www to HTTPS without www
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Redirect HTTPS with www to HTTPS without www
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule .* https://%1%{REQUEST_URI} [R=301,L]

Related Links

Apache2 ProxPassReverse with tomcat redirection and context
Spotfire Redirecting to home after link click
how to get url redirect video from lh3.googleusercontent with PHP
Cloudflare redirect subdomain to URL
How to redirect all pages in a subfolder to a single page
Redirecting a link to the same page if the page of that url is already opened
How to redirect and keep the original url unchanged?
Redirection handling in ROKU
Redirect script not working in Internet Explorer
Capture PersonID from INSERT statement and use it to redirect to details page
How do I disallow search robots from www.example.com and exsample.com
How to redirect a page while counting page hits?
Redirect any outbound traffic to local IP
htaccess redirecting with NC parameter
Having troubles in cPanel with a redirect
How to cancel redirection of page with click?

Categories

HOME
shell
eslint
css3
phpmyadmin
swt
numbers
shiro
yandex
limit
jetty
crystal-reports-2013
nfs
rcloud
jsonpath
flatpak
linear-algebra
html5-appcache
imessage
topology
symbols
asciidoctor-pdf
undertow
imagemap
exit
opentk
quantlib
alm
catch-unit-test
spring-security4
mailkit
activexobject
installscript
searchkit
dm-script
odoo-website
datacachefactory
naming
photos
phpdbg
puredata
textsum
gitlist
cnc
convex-optimization
zenhub
oracleclient
truezip
monkey
objectscript
vibrate
rxtx
rsa-archer-grc
microstation
burrows-wheeler-transform
greatest-n-per-group
nikeplus-api
mapinfo
tooleap
http-status-code-401
cfchart
mediametadataretriever
grass
jnlua
custom-errors
themoviedb-api
avisynth
wiredep
include-guards
ons-api
typemock
amiga
telepat
shopizer
procedural-programming
browserify-shim
ss7
cancellation
alternate
jquery-slider
vsx
file-not-found
high-resolution
ora-06550
flex++
octal
superscrollorama
mysql-error-2013
wimax
uimanageddocument
apache-commons-dbutils
agility.js
denied
google-floodlight
rmdir
unattended-processing
msr
tmx
django-paypal
photolibrary
ruby-1.8
purepdf
wcf-instancing
sun
cldc
dojo-dnd
flvplayback
leader
wspbuilder

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App