如何在htaccess中为一个插件域重写http到https

时间:2015-05-29 02:58:00

标签: .htaccess

我在Godaddy有一个cPanel托管帐户,其中包含一个用于插件域的SSL。我需要将http重写为https。问题是所有重写方法都是从webroot加载,而不是包含索引的文件夹,甚至是具有重写规则的htaccess。我知道在这个论坛上已有相关主题,但我已尝试过这些建议的解决方案,这就是我在代码引用中看到的内容,但它们没有用。请不要随意关闭此帖子。

webroot (loading this content / not desired)
      |
       target_directory (htaccess & SSL in question)

以下是本文发布时的完整htaccess

RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} off
#RewriteRule (.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteRule (.*)$ https://emeraldcoast\.rocks/$1 [R,L]

RewriteRule ^([a-zA-Z0-9\-_]+)$ index.php?page=$1
RewriteRule ^([a-zA-Z0-9\-_]+)/$ index.php?page=$1

<filesMatch ".(xml|txt|html|js|css)$">
ExpiresDefault A7200
Header append Cache-Control "max-age=290304000, public"
</filesMatch>
<filesMatch ".(xml|txt|html|php)$">
AddDefaultCharset utf-8
</filesMatch>
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>

1 个答案:

答案 0 :(得分:0)

使用控制面板尤其是cpanel可以控制服务器并配置与标准设置不同的东西。无论如何,您可能需要在您的插件域中添加重写库。在插件域内部.htaccess将rewritebase更改为您的插件文件夹。

RewriteBase /target_directory