.htaccess - htaccess url 重写和 https
问题描述
我有一个以前在服务器上设置为 http 地址的网站。现在我更改了服务器,网站应该是 https。
所以我决定在.htaccess文件中进行更改,但它不起作用(500错误,网页没有出现)
这是我的 htaccess 文件内容:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
#allow to add "www." if missing
RewriteCond %{HTTP_HOST} !^www\.mywebsite\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/?(.*) https://www.mywebsite.com/$1 [L,R,NE]
php_flag "allow_url_fopen" "On"
# URL rewrites
RewriteRule ^home$ /index.php?content=home&lang=en [L]
RewriteRule ^home-notice-1$ /index.php?content=home&val=1&lang=en [L]
RewriteRule ^home-notice-2$ /index.php?content=home&val=2&lang=en [L]
RewriteRule ^home-notice-3$ /index.php?content=home&val=3&lang=en [L]
RewriteRule ^featured-news$ /index.php?content=news&mode=featured&lang=en [L]
etc...
有人可以告诉我有什么问题吗?基本上,与以前相比,我所做的只是添加了“RewriteCond %{HTTPS} off”并将“RewriteRule ^/?(. ) http:...”更改为“RewriteRule ^/?(. ) https:... ”。当然,“mywebsite.com”是我网站真实名称的占位符,我显然输入正确。
从 ftp 客户端的角度来看,这似乎是结构:
从根目录到 index.php:
->rb4t7.ftp.mywebhost.com
->sites (folder)
->mywebsite.com (folder)
.htaccess (file)
index.php (file)
...
谢谢
解决方案
好的,我所要做的就是复制/粘贴“#URL Rewrites”下面的部分。显然,其他一切都在搞乱系统。https 以某种方式在本地得到了照顾。谢谢
推荐阅读
- python - 我正在尝试从 at the races 网站上抓取数据,但抓取工具没有返回任何结果
- node.js - Firebase 图像上传,通过云功能 (https) 调整大小,并保存到 firestore
- python - 在 Python 上使用 Selenium 查找元素
- c# - 删除堆栈的最后一项
- angularjs - 如何从 Javascript 端获取 $Index
- javascript - Bootstrap Datepicker 日期范围选择器不允许选择 9 月 30 日
- android - android List View 适配器并将项目对象发送到另一个活动
- python - Python SQLite 正则表达式 ExecuteMany
- python - Python pandas 在时间间隔内查找数据
- c# - 如何创建一个新的虚拟列作为十进制(10,2)?MYSQL