道歉,如果這對某些人來說似乎很簡單。Canonical https和www
在我已經設置了301個重定向用的代碼片段,是在互聯網上過去:
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
但是,一些事情離開我不確定這個特殊的項目。
1)我使用HTTPS,所以有四個CNAMES現在(是(CNAME)正確的術語?) https://example.com https://www.example.com http://example.com http://www.example.com
2)我用一個CMS需要的.htaccess文件,以便在運行網站時搜索CSS和其他信息。因此,我作爲一個技術較低的人,擔心會亂動.htaccess文件(當這個文件丟失之前死於一個單獨的問題,該網站是不工作的)
問題: 1)它有問題嗎? int他.htaccess文件我把重定向?開始/結束文件? 2)如何修改上面的代碼片段以考慮https?
這裏是的.htaccess代碼
# Turn on URL rewriting only when mod rewrite is turn on
<IfModule mod_rewrite.c>
RewriteEngine On
# Installation directory
RewriteBase/
# Protect application and system files from being viewed
RewriteRule ^(application|modules|system|tests|sql) - [F,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?kohana_uri=$0 [L,QSA]
</IfModule>
# Protect the htaccess from being viewed
<Files .htaccess>
order allow,deny
deny from all
</Files>
# Don't show directory listings for URLs which map to a directory.
Options -Indexes
#Follow symlinks
Options +FollowSymlinks
也許這[幫助](http://stackoverflow.com/questions/2097542/use-htaccess-to-add-www-with-https-support)將有所幫助。 –
你想達到什麼目的? HTTPS會發生什麼或不會發生什麼? –
@Olaf我希望訪問者能夠到達一個域名,而不管他們進來的4個變體中的哪一個:https://example.com –