0

This is my current .htaccess file. My project has https:// already but i wanted to open specific url without https . Is there any way i could forces one specific url to http?

<IfModule mod_rewrite.c>
        <IfModule mod_negotiation.c>
            Options -MultiViews
        </IfModule>

        RewriteEngine On

        # Redirect Trailing Slashes If Not A Folder...
        RewriteCond %{HTTPS} off
        RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


        # Handle Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]

        # Handle Authorization Header
        RewriteCond %{HTTP:Authorization} .
        RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    </IfModule>
Hola
  • 2,163
  • 8
  • 39
  • 87

1 Answers1

0

Sure you can do:

Options -MultiViews
RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} !/specific-url [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{THE_REQUEST} !/specific-url [NC] will skip /specific-url for http -> https redirection.

anubhava
  • 761,203
  • 64
  • 569
  • 643
  • suppose the url which i don't want to open with https is `abc.com/demo` the should i write `RewriteCond %{THE_REQUEST} !/demo [NC]` – Hola Jan 16 '18 at 16:49
  • @anubhava Can it be somehow passed multiple exact URLs in oneliner like array or list? – Tpojka Jan 16 '18 at 20:37
  • Yes it can be done e.g. `RewriteCond %{THE_REQUEST} !/(demo|demo1|demo2) [NC]` – anubhava Jan 16 '18 at 20:39
  • I did but noting happened actually.The url which i don't want to open with https still loads with https – Hola Jan 17 '18 at 08:15
  • Test in a new browser or use command line curl for testing. Also update question with latest .htaccess – anubhava Jan 17 '18 at 08:17
  • btw this rule only prevents `http -> https` redirection. So your URL should be: `http://example.com/demo` (not https) – anubhava Jan 17 '18 at 08:18