0
現在我有這樣的代碼重定向非www到www以https不包括CDN及其他子域
RewriteEngine On
RewriteBase/
# remove the .html extension
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.html\ HTTP
RewriteRule (.*)\.html$ $1 [R=301]
# remove index and reference the directory
RewriteRule (.*)/index$ $1/ [R=301]
# remove trailing slash if not a directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]
# forward request to html file, **but don't redirect (bot friendly)**
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.html [L]
#First rewrite any request to the wrong domain to use the correct one (here www.)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#Now, rewrite to HTTPS:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
其工作完全正常,但它是從cdn.domain.com/img重定向我們的CDN圖像。 JPG到www.domain.com/img.jpg我如何防止這種情況發生?
它仍然將cdn.domain.com/url/img.jpg重定向到www.domain.com/url/img.jpg – user1573389 2014-10-31 16:39:03
我在哪裏添加代碼,是否可以在OP中檢查我刷新的代碼。 – user1573389 2014-10-31 16:42:42
當您在開始處放置此規則時,所有針對'cdn.domain.com'的請求都不會被重寫。 – 2014-10-31 17:27:41