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

How do I use redirections and the Google search console?
OPENWRT : Redirect all wireless client's http/https traffic to the local webserver?
HAProxy redirect to subdomain
Gtmetrix Mimimize Redirect Chains
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

Categories

HOME
embedded
kentico
spark-streaming
apache-jena
android-studio-2.2
oracle-apex-5
gembox-spreadsheet
onclick
pcl-crypto
datastage
ipmitool
dynatrace
event-sourcing
mapstruct
sse
cfml
inno-download-plugin
php-mysqlidb
stackexchange
appirater
winexe
twiml
ntp
alm
activexobject
joomla2.5
reverse
batching
salesforce-communities
lint
imagenet
modernizr
node-mssql
health-monitoring
apache-stanbol
claims
opencmis
double-click
spring-integration-sftp
configurationmanager
magic-draw
azure-cli
structuremap4
grails-plugin
autosar
hadoop-2.7.2
gogs
simevents
cassia
uiactionsheet
fuzzywuzzy
cycle2
spring-retry
directdraw
decimalformat
opl
opserver
dbaccess
big-ip
sql-scripts
jquery-slider
ecslidingviewcontroller
ora-06550
sphinxql
model-driven-development
observium
flex++
android-icons
asplinkbutton
luabind
workflow-services
htdocs
umra
inline-formset
commerceserver2007
message-passing
lobo-cobra
mathematical-notation
sun
asynchronous-wcf-call
todos
fault-tolerance
fdf

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile