这不行,我从商店和大学获得了许多重定向
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} !=on
#RewriteCond %{REQUEST_URI} ^/shop$ [NC]
RewriteRule ^(shop/.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteBase /shop/
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(university/.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteBase /university/
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} !^(shop/.*)$ [NC]
RewriteCond %{REQUEST_URI} !^(university/.*)$ [NC]
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
如何制作正确的重定向?
答案 0 :(得分:0)
您可以使用:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(shop|university)(/.*)?$ https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]
RewriteCond %{HTTPS} on
RewriteRule !^(shop|university)(/.*)?$ http://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]
</IfModule>