简体   繁体   中英

I want to redirect specific url to non https using htaccess

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.

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.

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 .

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM