Rewrite Rule to Work on HTTP and HTTPS

10,870

Apache uses a different vhost for ssl configuration:

<IfModule mod_ssl.c>
  <VirtualHost _default_:443>
  RewriteEngine on
  RewriteCond %{HTTP_HOST} ^www\.siku-siku\.com$
  RewriteRule ^/work/all.html  /portfolio/ [L,R=301]
  ...
  </VirtualHost>
</IfModule>

This link has an example for configuring Apache with SSL on Debian, but should be easy to extrapolate to whichever platform you are on http://www.debian-administration.org/articles/349

Share:
10,870
moey
Author by

moey

Updated on June 22, 2022

Comments

  • moey
    moey almost 2 years

    I have this simple rewrite rule and it works properly under http:

    RewriteCond %{HTTP_HOST} ^www\.siku-siku\.com$
    RewriteRule ^/work/all.html  /portfolio/ [L,R=301]
    

    However, the rule doesn't take into effect when I was on https. I modified the rule set to the following but to no avail.

    RewriteCond %{HTTPS} on
    RewriteCond %{HTTP_HOST} ^www\.siku-siku\.com$
    RewriteRule ^/work/all.html  /portfolio/ [L,R=301]
    

    How can I make that rule to work both on http and https? Please let me know if I need to provide more information.