【发布时间】:2012-08-14 20:00:47
【问题描述】:
我已经搜索过,虽然我发现很多线程都关闭了,但没有一个是我正在寻找的......
在我的网站上,例如 example.com,我创建了子域 secure.example.com
此子域将具有 SSL。
我想要做的是将请求重定向到 https://secure.example.com/path/ 到 www.example.com/path/,同时保持 url 显示为 https://secure.example.com/path/
注意 subdomain.example.com 的目的是为了 SSL,所以上面的重定向需要使用 SSL
我想在 htaccess 中使用其他一些重定向: 1)将非www重定向到www忽略子域(所以secure.example.com不会变成www.secure.example.com) 2) 将/index.php 重定向到/ 3)最后但并非最不重要的一点是,在secure.example.com上强制使用SSL
此外,购物车软件还有其他功能和 SEO 的 htaccess 语句,如下所示。
我当前的根 htaccess:
# Prevent Directoy listing
Options -Indexes
# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
Order deny,allow
Deny from all
</FilesMatch>
# Turn Rewrite Engine On
RewriteEngine On
## index.php to root
Options +FollowSymlinks
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.example.com/ [R=301,L]
## non-www to www ignore subdomains
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
【问题讨论】:
-
example.com和secure.example.com是否在同一主机和同一文档根目录上?你有加载 mod_proxy 吗? -
是的,它们位于同一主机和同一文档根目录上。子域实际上是根设置下带有子域的子文件夹。在我的主机的帮助下,我们现在可以正确解析并安装 SSL。
-
唯一剩下的就是我原来帖子中的重定向。至于 mod_proxy,我不知道,但我敢打赌它没有安装。我给我的主人寄了一张票来确定一下。
-
我的主机说安装了 mod_proxy。我的 Apache 配置显示这些已安装:proxy_module(静态)proxy_connect_module(静态)proxy_ftp_module(静态)proxy_http_module(静态)proxy_ajp_module(静态)proxy_balancer_module(静态)
标签: security .htaccess redirect ssl subdomain