gpt4 book ai didi

.htaccess - 如果页面 url 包含特定单词,如何禁用 SSL

转载 作者:太空宇宙 更新时间:2023-11-03 13:07:22 25 4
gpt4 key购买 nike

我的网站在所有 SSL 上运行,但我添加了一个使用 Flash 中的第 3 方游戏的游戏部分。当我启用 SSL 时,它停止工作。我想知道我是否只能在 url 中包含“/game/”的特定页面上禁用 SSL,以便游戏正常运行。

我在我的 .htaccess 文件中尝试了来自 insternet 的这段代码,但没有工作:

RewriteCond %{HTTPS} off
RewriteRule ^game^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

编辑:

我尝试了建议的答案:

RewriteEngine On
RewriteCond %{HTTPS} On [NC]
RewriteRule ^game http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NC]

它有效,但是当我转到包含“游戏”一词的页面时,它会将其他页面也变成“http”,而其他页面则变成使用“http”而不是“https”

然后我试了一下:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} On [NC]
RewriteRule ^game http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NC]

当我转到“游戏”页面 url 时,它开始给我消息“页面未正确重定向”。

我只希望“游戏”页面使用“http”。

编辑二:完整的 .htaccess 文件

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Get rid of index.php
RewriteCond %{REQUEST_URI} /index\.php
RewriteRule (.*) index.php?rewrite=2 [L,QSA]

# Rewrite all directory-looking urls
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*) index.php?rewrite=1 [L,QSA]

# Try to route missing files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} public\/ [OR]
RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$
RewriteRule . - [L]

# If the file doesn't exist, rewrite to index
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA]

</IfModule>

# sends requests /index.php/path/to/module/ to "index.php"
# AcceptPathInfo On

# @todo This may not be effective in some cases
FileETag Size

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</IfModule>

需要帮助。如果发现任何重复项,请告诉我,但我找不到任何人。谢谢。

最佳答案

这应该是您的完整 .htaccess:

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On

# except for /game/ enforce https
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} !/game/ [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# for /game/ enforce http
RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} /game/ [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Get rid of index.php
RewriteCond %{REQUEST_URI} /index\.php
RewriteRule (.*) index.php?rewrite=2 [L,QSA]

# Try to route missing files
RewriteCond %{REQUEST_FILENAME} public [OR]
RewriteCond %{REQUEST_URI} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$
RewriteRule . - [L]

# If the file doesn't exist, rewrite to index
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA]

</IfModule>

确保在测试此更改之前清除浏览器缓存。

关于.htaccess - 如果页面 url 包含特定单词,如何禁用 SSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32985452/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com