【发布时间】:2013-04-05 16:01:27
【问题描述】:
抱歉,如果这对某些人来说似乎很简单。
在过去,我使用遍布互联网的 sn-p 代码设置了 301 重定向:
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
但是,对于这个特定的项目,有些事情让我不确定。
1) 我使用的是 https,所以现在有四个 CName((CName)是正确的术语吗?) https://example.com https://www.example.com http://example.com http://www.example.com
2) 我正在使用需要 .htaccess 文件的 CMS,以便在运行网站时搜索 CSS 和其他信息。因此,作为一个技术含量较低的人,我担心摆弄 .htaccess 文件(当此文件丢失之前,由于一个单独的问题导致网站无法正常运行)
问题: 1)我将重定向放在他的 .htaccess 文件中的位置是否重要?文件的开始/结束? 2) 我将如何更改上面的 sn-p 以考虑 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
【问题讨论】:
-
也许这个answer 会有所帮助。
-
你想达到什么目的? HTTPS 应该发生什么?
-
@Olaf 我希望访问者访问一个域名,无论他们访问了 4 个变体中的哪一个:example.com
标签: .htaccess mod-rewrite redirect https http-status-code-301