1

I have installed into a sub-folder of my domain a Web App. Example: domain.com/webapp

I want to use the Web App with SSL enabled: https://domain.com/webapp

I want to redirect at same time: WWW to NON-WWW and HTTP to HTTPS only for the sub-folder "webapp".

Trying with the code fund in this website didn't actually work 100%, having issues with to many redirects, or redirecting me to the site root not subfolder, etc.

Thanks for your help.

2 Answers2

0

You can try this code in your .htacess file in the root.

RewriteEngine On
RewriteCond %{HTTPS} !^on [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^webapp/?(.*?)$ https://example.com/webapp/$1 [R=301,L]

If you have htaccess file inside the webapps folder, then you can try this.

RewriteEngine On
RewriteBase /webapps
RewriteCond %{HTTPS} !^on [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
Panama Jack
  • 24,158
  • 10
  • 63
  • 95
  • @MariusModoranu Where is your .htaccess file? And what exactly doesn't work? What is it doing or not doing? I also updated my answer. – Panama Jack Jun 06 '15 at 09:07
  • Some of the links were taking my to the https://domain.com and I prefer editing the .htaccess in domain.com/webapp – Marius Modoranu Jun 06 '15 at 11:36
  • @MariusModoranu why are you unaccepting the answers? You do know that if both answers have helped you, you can at least up vote the answer. – Panama Jack Jul 03 '15 at 12:17
0

Inside /webapp/.htaccess use this rule:

RewriteEngine On

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://domain.com/%{REQUEST_URI} [R=301,L,NE]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • 1
    Thanks! It works. This is perfect, doesn't interact with other installations in the domain's folders or with the main domain installation. – Marius Modoranu Jun 06 '15 at 11:37