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

Masking an URL after redirect
How to redirect without change url?
.Search bar not storing history correctly on redirect from separate search page
301 redirect index.html to index.php and hide index.php from the url
Check redirect rules from .htaccess file
301 Redirect with limited access to site
How to create a custom expression to 301 redirect multiple html pages to a single page
URL Rewrite Module and Folder Redirects
handling URI redirect response in OAuth2 user agent flow
url redirecting + tracking
site The page isn't redirecting properly
Redirection With https from www to non-www
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

Categories

HOME
android
phantom-dsl
scikit-learn
angular-formly
depth
hessian
mstest
devise
boto3
recordrtc
vimdiff
ibeacon-android
why3
zerobrane
flatpak
android-intent
event-sourcing
job-scheduling
asp.net-mvc-viewmodel
pyramid
foreign-keys
database-connection
selinux
windows-xp
zxing
flask-sqlalchemy
game-theory
winexe
sinch
errbot
event-flow
kodi
dumpbin
android-sugarorm
latitude-longitude
watchman
google-earth-engine
graphhopper
dm-script
z-notation
hackintosh
signals-slots
azure-arm
preloader
sharp-snmp
outputcache
clang++
optimizely
dynamic-linq
colorbar
cmp
py2neo
ampps
materialized-path-pattern
taocp
grails-plugin
flex-monkey
seek
vulcanize
cassia
mediametadataretriever
query-by-example
findfirst
cycle2
jparsec
concept-insights
relativelayout
iokit
dllimport
amiga
ocra
sql-server-data-tools
airbrake
keyup
alloy-ui
android-broadcast
viewer
filesplitting
sip-server
cbind
wcm
trdion2011
ignite-ui
cancellation
ray
qscrollarea
gd-graph
ie8-compatibility-mode
script#
http-status-code-410
alice
robotlegs
faye
window-decoration
apache-commons-dbutils
node-redis
rmdir
timthumb
squishit
load-time
hbm2java
lalr
visualj#
dsoframer
httpcookie

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