1

I am using following rule of .htaccess to redirect site from http to https.

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

But my site code is placed under folder Testversion. So when I add this rule in .htaccess file, my url becomes "https://abcd.com/Testversion" instead of "https://abcd.com"

Any one knows how I can skip Testversion folder name ?

Gokul Shinde
  • 957
  • 3
  • 10
  • 30
  • possible duplicate of [Reference: mod\_rewrite, URL rewriting and "pretty links" explained](http://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained) – dori naji Feb 03 '15 at 10:46

1 Answers1

2

If your .htaccess is placed inside a subdirectory then you can use:

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{SERVER_NAME}/$1 [R,L]

i.e. capture relative URI (from current directory) from RewriteRule and use it in the target.

anubhava
  • 761,203
  • 64
  • 569
  • 643