Handling subdomains and https with .htaccess

前端 未结 1 1074
轮回少年
轮回少年 2021-01-28 11:19

In the .htaccess example below, if someone types in a URL like the following...

http://mysite.com/ricks-motorcycles

...it will automatically load the page from x

1条回答
  •  梦毁少年i
    2021-01-28 12:02

    You can qualify your rewrites with a RewriteCond:

    RewriteEngine On
    
    RewriteCond %{HTTPS} =on
    RewriteRule ^ricks-motorcycles/(.*)$ https://example.com/ricks-motorcycles/$1 [P,L]
    
    RewriteCond %{HTTP_HOST} =ricks-motorcycles.mysite.com
    RewriteRule ^(.*)$ http://example.com/ricks-motorcycles/$1 [P,L]
    

    For more information, see the mod_rewrite documentation.

    0 讨论(0)
提交回复
热议问题