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

outlook calendar api redirection uri with vhost , not working
Redirect address when IP and port are mapped to domain
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

Categories

HOME
c++11
powerpoint
numbers
hessian
gradient
soa
parameters
vxml
hugo
babeljs
project
pcl-crypto
project-intu
angular-dart
naivebayes
symmetricds
cumulocity
video-editing
foreign-keys
database-connection
rubymotion
named-entity-recognition
dataflow-diagram
scriptella
beautifier
slidetoggle
datastax-enterprise-graph
winpe
send
mobx
kudu
catch-unit-test
keras-layer
sharding
pdw-file-browser
lint
modernizr
projects-and-solutions
ods
p4merge
datacachefactory
preloader
apollostack
knime
file-sharing
libgphoto2
openrasta
scalding
universal-analytics
vibrate
sandcastle
cvxpy
taocp
meteor-packages
microstation
xdoclet
sklearn-pandas
nio2
np-spring
vigenere
morton-number
include-guards
video-player
sony-lifelog-api
snoop
telepat
xmltype
cross-join
webmatrix-3
easyrtc
wxformbuilder
paste
renderer
qscrollarea
sbcl
xmltodict
gwt-openlayers
notorm
asdf
chart-director
joomla3.1
fitbounds
wiimote
cross-database
stress
flex-mobile
event-receiver
cac
vs-android
tui
cuda.net
sun
dojo-dnd
ifilter

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