AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-433041

TSA's questions

Martin Hope
TSA
Asked: 2017-09-25 10:57:15 +0800 CST

.htaccess 代码将 HTTP 请求重定向到 HTTPS

  • 0

我最近将我的网站从 HTTP 迁移到 HTTPS。.htaccess我在各种网站上阅读了有关使用代码将所有 HTTP 请求重定向到 HTTPS 的信息。

许多网站提供不同的代码,现在我很困惑应该使用哪个代码。

以下是在各种网站上找到的 4 个代码:

第一个代码:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.yoursite.com [NC]
RewriteRule ^(.*)$ https://www.yoursite.com/$1 [L,R=301,NC]

第二个代码:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

第三个代码:

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

第四个代码:

NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.example.com
Redirect permanent / https://secure.example.com/
</VirtualHost>

<VirtualHost _default_:443>
ServerName secure.example.com
DocumentRoot /usr/local/apache2/htdocs
SSLEngine On
</VirtualHost>

请指导我哪个代码是完美的,我应该把它放在我的.htaccess文件中吗?

.htaccess
  • 1 个回答
  • 87 Views
Martin Hope
TSA
Asked: 2017-09-22 04:54:02 +0800 CST

.htaccess 代码用于阻止名称中包含 Windows 2001-2009 的 UserAgent

  • 1

我正在尝试阻止名称中包含以下内容的用户代理:

Windows 2001
Windows 2002
Windows 2003
Windows 2004
Windows 2005
Windows 2006
Windows 2007
Windows 2008
Windows 2009

我将在.htaccess文件中使用以下代码:

RewriteCond %{HTTP_USER_AGENT} .*Windows\ 200[1-9].* [NC]
RewriteRule ^(.*)$ - [F,L]

上面的代码是正确的还是有其他正确形式的代码可以做到这一点?

.htaccess
  • 1 个回答
  • 520 Views
Martin Hope
TSA
Asked: 2017-09-09 23:57:52 +0800 CST

.htaccess 文件大小是否重要?

  • 0

我想知道文件大小有.htaccess关系吗?我在某处读到大.htaccess文件会降低网站性能。

我的.htaccess文件大小是51KB它包含500 lines的主要是RewriteCond %{HTTP_REFERER}阻止垃圾邮件引荐网站的规则。

但我没有注意到任何网站加载滞后或性能问题。

如果我将这 500行转换为 20 行,每行包含 25 个使用和符号RewriteCond %{HTTP_REFERER}分组的垃圾邮件引荐来源域名,它会改变什么吗?()|

例如转换以下行:

RewriteCond %{HTTP_REFERER} hol\.es [NC,OR]
RewriteCond %{HTTP_REFERER} hys\.cz [NC,OR]
RewriteCond %{HTTP_REFERER} zzz\.com\.ua [NC,OR]
RewriteCond %{HTTP_REFERER} hypersito\.com [NC,OR]
RewriteCond %{HTTP_REFERER} tode\.cz [NC,OR]
RewriteCond %{HTTP_REFERER} mzf\.cz [NC,OR]

如下:

RewriteCond %{HTTP_REFERER} (hol\.es|hys\.cz|zzz\.com\.ua|hypersito\.com|tode\.cz|mzf\.cz) [NC,OR]

它会减少 CPU 负载并减少 CPU 周期吗?还是会保持与拥有 500 条单独的行相同?

.htaccess
  • 1 个回答
  • 1688 Views
Martin Hope
TSA
Asked: 2017-09-07 02:47:53 +0800 CST

.htaccess 代码阻止所有 .ua 域,但将特定域列入白名单

  • 2

我正在使用以下.htaccess代码阻止一些垃圾邮件引荐来源:

RewriteCond %{HTTP_REFERER} \.ru$ [NC,OR]
RewriteCond %{HTTP_REFERER} \.ru/ [NC,OR]
RewriteCond %{HTTP_REFERER} \.ua$ [NC,OR]
RewriteCond %{HTTP_REFERER} \.ua/ [NC,OR]
RewriteCond %{HTTP_REFERER} hol\.es [NC,OR]
RewriteCond %{HTTP_REFERER} hys\.cz [NC,OR]
A few more similar lines
RewriteCond %{HTTP_REFERER} slinqs\.com [NC]
RewriteRule ^(.*)$ - [F,L]

如您所见,我已使用该代码阻止了.ru所有域。.ua

现在的问题是我想允许特定.ua域向我的网站发送流量。

我怎样才能将那个.ua域列入白名单?

可能吗?

.htaccess
  • 1 个回答
  • 358 Views
Martin Hope
TSA
Asked: 2017-08-29 04:13:51 +0800 CST

如何查看 403 禁止错误页面?

  • 0

我们如何知道我们的服务器是否完美地给出了 403 禁止错误?我想知道,因为我使用了用于阻止引荐网站和垃圾邮件机器人的 .htaccess 文件的代码。

 <IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteCond %{HTTP_REFERER} domain1\.com [NC,OR]
 RewriteCond %{HTTP_REFERER} domain2\.com [NC,OR]
 RewriteCond %{HTTP_REFERER} domain3\.com [NC]
 RewriteRule ^(.*)$ - [F,L]
 </IfModule>

我使用该代码阻止了一个网站,但是当我访问该网站并单击我的网站链接时,我的网站对我来说可以正常打开。由于引荐网站在 .htaccess 文件中列出,我不应该收到 403 禁止页面吗?

如何检查我的网站是否支持 403 禁止页面?代码是否正确?

forbidden
  • 2 个回答
  • 3790 Views
Martin Hope
TSA
Asked: 2017-08-29 02:31:15 +0800 CST

允许、拒绝或要求所有 .htaccess 中的不同 Apache 版本

  • 3

当我们想要使用 .htaccess 文件阻止机器人、垃圾邮件引荐来源网址时,一些网站使用以下代码语法:

Order allow,deny
Allow from all
Deny from env=spambot

但是有些网站告诉我们需要为不同的 Apache 版本使用不同的代码:

#For Apache 2.2
<IfModule !mod_authz_core.c>
<IfModule mod_authz_host.c>
    Order allow,deny
    Allow from all
    Deny from env=spambot
</IfModule>
</IfModule>

# For Apache 2.4
<IfModule mod_authz_core.c>
<RequireAll>
    Require all granted
    Require not env spambot
</RequireAll>
</IfModule>

现在我想哪个锥体是正确的或两者都是正确的?

.htaccess
  • 1 个回答
  • 8254 Views
Martin Hope
TSA
Asked: 2017-08-29 01:47:39 +0800 CST

在 .htaccess 代码中的域名中使用 DOT 之前的“\”

  • 2

许多网站提供 .htaccess 代码来阻止垃圾邮件程序、垃圾邮件推荐等。

有些网站在“.”之前使用“\”。在域名中。例如:

RewriteCond %{HTTP_REFERER} spamdomain\.com [NC,OR]

SetEnvIfNoCase Referer spamdomain\.com spambot=yes

但有些网站使用直接域名。例如:

RewriteCond %{HTTP_REFERER} spamdomain.com [NC,OR]

SetEnvIfNoCase Referer spamdomain.com spambot=yes

现在我很困惑哪种代码语法是正确的?两个代码都可以正常工作吗?我应该使用哪一个?

.htaccess
  • 1 个回答
  • 2459 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve