1

I am forcing HTTPS and redirecting to subdirectory with:

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301]

RewriteCond %{HTTP_HOST} ^domain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule (.*) /www_domain_com/$1

and all is working, but http://www.domain.com. I see in browser address bar: https://www.domain.com/www_domain_com/.

My goal is to remove this subdirectory from url and have ssl in all requests and all requests redirected to that subdirectory.

hjpotter92
  • 660
  • 1
  • 10
  • 20

1 Answers1

0

First it's worth making sure you have the following line in your conf file:

 RewriteEngine On

Then try the following:

RewriteCond %{HTTP_HOST} ^domain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule (.*) https://www_domain_com%{REQUEST_URI}

I have them merged in my conf file, here's the combined version:

RewriteEngine On
RewriteCond %{HTTPS} off [NC, OR]
RewriteCond %{HTTP_HOST} !^domain.com [NC, OR]
RewriteCond %{HTTP_HOST} !^www.domain.com [NC]
RewriteRule (.*) https://domain.com%{REQUEST_URI}
BenD10
  • 23
  • 7