• Hello! I have in my htaccess the following code to redirect all http urls to https:

    RewriteCond %{HTTPS} !on
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    This works great, but now I need to allow to access by http only to one specific url: /feed/products/

    So I edited the code to this

    RewriteCond %{HTTPS} !on
    RewriteCond %{REQUEST_URI} !^/feed/products/
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    The problem is what when I enter https://mydomain.com/feed/products/ instead of keep in https://mydomain.com/feed/products/ that is what I expected, it redirects to the home page.

    What is the problem? I don′t know much about htacces. Thank you!!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You can try something like this, but it will probably not work if your WordPress General Settings are like the settings shown below. If you have mixed URL’s on your website then most likely a redirect loop problem will occur. You cannot use both http and https URL’s in the Source Code of a website page. All URL’s in a page that is http must be http, all URL’s in a page that is https must be https.

    WordPress General Settings:
    WordPress Address (URL) https://www.your-domain-name.com
    Site Address (URL)      https://www.your-domain-name.com

    Give this a try, but most likely it will not work.

    # WP REWRITE LOOP START
    # Rewrite|Redirect http to https|SSL
    RewriteEngine On
    RewriteBase /
    RewriteRule ^feed/products/ https://example.com/feed/products/ [R,L]
    RewriteCond %{HTTPS} !=on
    RewriteCond %{SERVER_PORT} ^80
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
    RewriteRule ^index\.php$ - [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # WP REWRITE LOOP END
    Thread Starter Lois

    (@loiscr)

    Thanks! I tried your code but it didn′t work.

    If this works:
    RewriteCond %{HTTPS} !on
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    I don′t understand why this not works:
    RewriteCond %{HTTPS} !on
    RewriteCond %{REQUEST_URI} !^/feed/products/
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    I have only added a exception. Not changes in the rewrite rule. Its apparently impossible. Any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘redirect all urls from http to https except one url’ is closed to new replies.