.htaccess - 配置文件夹以使用 SSL

标签 .htaccess ssl

我有一个域:http://example.xoc.uam.mx .我想要求在其中使用 SSL(它是服务器的文件夹)。我在 .htaccess 中有这段代码,但它不起作用。我做错了什么?

    RewriteEngine On 
    RewriteCond %{SERVER_PORT} 80 
    RewriteCond %{REQUEST_URI} ^example\.xoc\.uam\.mx$ [NC]
    RewriteRule ^(.*)$ https://example.xoc.uam.mx$1 [R,L]

附言。我已经拥有所有 SSL 功能,我认为这是我唯一想念的东西。

最好的问候。

最佳答案

您的代码有一些错误。要解析域名,您必须使用 HTTP_HOST 而不是 REQUEST_URI

你可以用这个代替它

RewriteEngine On 
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^example\.xoc\.uam\.mx$ [NC,OR]
RewriteCond %{HTTP_HOST} ^111\.222\.333\.444$
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]

关于.htaccess - 配置文件夹以使用 SSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26108018/

相关文章:

php - 重写规则不允许我访问我域的 index.php

apache - 使用 mod_rewrite 维护查询字符串

git - 如何防止自述文件可通过网络访问

php - 权限被拒绝 :/var/www/abc/. htaccess pcfg_openfile : unable to check htaccess file, 确保它是可读的?

php - 警告 : stream_socket_enable_crypto(): SSL operation failed with code 1

apache - centos 7上Nginx反向代理apache,同时配置http和https

apache - .htaccess 重定向添加哈希,同时保留查询字符串

ios - 动态证书固定

ssl - 如何在 Nginx 中为自定义位置设置双向 SSL?

ssl - 如何使用 BrowserMob 代理拦截 SSL 请求