【发布时间】:2018-08-07 00:26:14
【问题描述】:
我正在尝试重定向论坛索引以对所有内容都使用 HTTPS,但 .htaccess 对我来说很新,我正在学习,所以任何人都可以帮忙,我将不胜感激 :)
所以我将论坛放在一个名为 SMF 的子目录中。目前一切都在 www.website.net/smf/index.php
但我想将所有内容重定向到 HTTPS,同时保留 /smf/index.php 结构。
这是我在主 html_public 中的当前 .htaccess:
# .htaccess main domain to subdirectory redirect
# Do not change this line.
RewriteEngine on
# Change example.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subdirectory/
# Don't change the following two lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /subdirectory/$1
# Change example.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ subdirectory/index.php [L]
当我改变任何东西时,一切都会变得很糟糕。论坛中的所有内容都在子目录文件夹中,包括 index.php 等。 (请注意我将网站 url 更改为 example.com 和子目录,仅在复制粘贴代码中更改为子目录)
我正在努力让网站显示 https,但是每当我尝试某些东西时它都不起作用并给我https://www.website.com//smf/index.php 并且我无法删除 // :(
我是否可以清理代码并使其更简单易懂?
谢谢!
【问题讨论】: