LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-08-2017, 01:11 PM   #1
Navdeep.D2
LQ Newbie
 
Registered: Dec 2016
Location: India,Punjab
Posts: 8

Rep: Reputation: Disabled
Redirect Main domain and subdomain from http to https


hello,
i want to redirect these sub domains and main domain from http to https and sub blogs too.
Home directories
WWW (Wordpress): /home1/placehq5/public_html/.htaccess
My Somadome (PHP): /home1/placehq5/public_html/my
Kiosk site (HTML): /home1/placehq5/public_html/kiosk
Config
Webserver is Apache version 2.2.31 (on Linux)

please correct this htaccess file.
Code:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://somadome.com/$1 [L,R=301]

RewriteCond %{SERVER_PORT} 443
RewriteCond %{HTTP_HOST} ^www[.].+$
RewriteRule ^(.*)$ https://somadome.com/$1 [L,R=301]
in this picture first column is how my urls are right now, 2nd column is what i want after htaccess rules, 3rd coulmn is what iam getting after applying these rule below:-

Click image for larger version

Name:	redirection rule htaccess.jpg
Views:	29
Size:	101.6 KB
ID:	24965
Please Help
 
Old 05-09-2017, 04:33 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,204
Blog Entries: 1

Rep: Reputation: 2059Reputation: 2059Reputation: 2059Reputation: 2059Reputation: 2059Reputation: 2059Reputation: 2059Reputation: 2059Reputation: 2059Reputation: 2059Reputation: 2059
Hi,

I would try:
Code:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301]

RewriteCond %{HTTP_HOST} ^www.somadome.com$
RewriteRule ^(.*)$ http://somadome.com/$1 [R=301,L]
 
  


Reply

Tags
htaccess, redirection


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] HTTPS in sub domain serves content from main domain. Wildcard SSL installed. amit.roy Linux - Server 17 11-25-2012 01:56 PM
Need help with http:// to https:// redirect PLEASE reaper75 Linux - Newbie 3 03-31-2012 04:57 PM
redirect https://www.domain.com to https://domain.com decenter Linux - Server 4 09-13-2011 10:05 AM
[SOLVED] Redirect Apache (mod_rewrite) from subdomain to https directory (vhost) accessthecloud Linux - Newbie 2 05-02-2011 07:07 AM
redirect http to https awreneau Linux - Server 17 10-14-2008 09:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration