1

my current htaccess is:-

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
   RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
</IfModule>

i want to add rule to htaccess for url like https://www.example.com/abc/arg1/arg2 should redirect to http://www.example.com/abc/arg1/arg2 for this https://www.example.com/abc/* it should redirect to non-https format with keeping all arguments.

Daljeet Singh
  • 704
  • 3
  • 7
  • 17

3 Answers3

0

Use below rule, check after clearing your cache.

RewriteCond %{REQUEST_URI} ^/abc/(.*) [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Edit: Please try with below rule,

RewriteCond %{REQUEST_URI} !^/abc/(.*) [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

In above rule we are appending https to all url which are not starting with abc/(.*) you have to use this rewritecond where your original https rule exists.

Abhishek Gurjar
  • 7,426
  • 10
  • 37
  • 45
0

If you want to redirect all https requests starting with abc/ to http, you must check for both abc/ and HTTPS

RewriteCond %{HTTPS} on
RewriteRule ^abc/ http://www.example.com%{REQUEST_URI} [R,L]

When everything works as it should, you may replace R with R=301 (permanent redirect). Never test with R=301.

Community
  • 1
  • 1
Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198
0

I am not sure how you achieve the job, but the following should be working perfectly for you.

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/abc [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
zarpio
  • 10,380
  • 8
  • 58
  • 71