0

我为我的网站获得了证书,现在我需要将其移至 https。这是我的 htaccess:

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /

# Protect hidden files from being viewed
<Files .*>
    Order Deny,Allow
    Deny From All
</Files>

# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]

我该怎么做?谢谢

4

1 回答 1

1

有几种方法可以做到;这是一个:

## port requirement (bail if not 443)
RewriteCond %{SERVER_PORT} !^443$
## exceptions
RewriteCond %{REQUEST_URI} ^/somepath$ [OR]
RewriteCond %{REQUEST_URI} ^/anotherpath$
## force traffic to https equivalent
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

我添加了 2 个可选的 RewriteCond 条目,允许您根据 URI 的第一个组件指定异常。

于 2012-07-18T22:12:30.750 回答