道歉,如果这对某些人来说似乎很简单。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 –