- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要使用 301 重定向将我的网站从 example.net
重定向到 www.example.net
。
我正在为我的网站使用一体式 WP 安全和防火墙,它会自动在我的 .htaccess 文件中添加其他代码。重定向不起作用,我认为这是由额外的代码引起的。我在浏览器中看到的错误是:
Too many redirects occurred trying to open www.example.net.
All In One WP 安全与防火墙会生成此类错误吗?
我的 301 代码:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^example.net [NC]
RewriteRule ^(.*)$ www.example.net/$1 [L,R=301,NC]
多合一代码:
# BEGIN All In One WP Security
#AIOWPS_BLOCK_WP_FILE_ACCESS_START
<Files license.txt>
order allow,deny
deny from all
</files>
<Files wp-config-sample.php>
order allow,deny
deny from all
</Files>
<Files readme.html>
order allow,deny
deny from all
</Files>
#AIOWPS_BLOCK_WP_FILE_ACCESS_END
#AIOWPS_BASIC_HTACCESS_RULES_START
<Files .htaccess>
order allow,deny
deny from all
</Files>
ServerSignature Off
LimitRequestBody 10240000
<Files wp-config.php>
order allow,deny
deny from all
</Files>
#AIOWPS_BASIC_HTACCESS_RULES_END
#AIOWPS_PINGBACK_HTACCESS_RULES_START
<Files xmlrpc.php>
order deny,allow
deny from all
</Files>
#AIOWPS_PINGBACK_HTACCESS_RULES_END
#AIOWPS_DISABLE_INDEX_VIEWS_START
Options -Indexes
#AIOWPS_DISABLE_INDEX_VIEWS_END
#AIOWPS_IP_BLACKLIST_START
Order allow,deny
Allow from all
#AIOWPS_IP_BLACKLIST_END
#AIOWPS_DISABLE_TRACE_TRACK_START
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
#AIOWPS_DISABLE_TRACE_TRACK_END
#AIOWPS_FORBID_PROXY_COMMENTS_START
RewriteCond %{REQUEST_METHOD} =POST
RewriteCond %{HTTP:VIA}%{HTTP:FORWARDED}%{HTTP:USERAGENT_VIA}%{HTTP:X_FORWARDED_FOR}%{HTTP:PROXY_CONNECTION} !^$ [OR]
RewriteCond %{HTTP:XPROXY_CONNECTION}%{HTTP:HTTP_PC_REMOTE_ADDR}%{HTTP:HTTP_CLIENT_IP} !^$
RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteRule .* - [F,NS,L]
#AIOWPS_FORBID_PROXY_COMMENTS_END
#AIOWPS_DENY_BAD_QUERY_STRINGS_START
RewriteCond %{QUERY_STRING} tag= [NC,OR]
RewriteCond %{QUERY_STRING} ftp: [NC,OR]
RewriteCond %{QUERY_STRING} http: [NC,OR]
RewriteCond %{QUERY_STRING} https: [NC,OR]
RewriteCond %{QUERY_STRING} mosConfig [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(globals|encode|localhost|loopback).* [NC,OR]
RewriteCond %{QUERY_STRING} (\;|'|\"|%22).*(request|insert|union|declare|drop) [NC]
RewriteRule ^(.*)$ - [F,L]
#AIOWPS_DENY_BAD_QUERY_STRINGS_END
#AIOWPS_ADVANCED_CHAR_STRING_FILTER_START
<IfModule mod_alias.c>
RedirectMatch 403 \,
RedirectMatch 403 \:
RedirectMatch 403 \;
RedirectMatch 403 \=
RedirectMatch 403 \@
RedirectMatch 403 \[
RedirectMatch 403 \]
RedirectMatch 403 \^
RedirectMatch 403 \`
RedirectMatch 403 \{
RedirectMatch 403 \}
RedirectMatch 403 \~
RedirectMatch 403 \"
RedirectMatch 403 \$
RedirectMatch 403 \<
RedirectMatch 403 \>
RedirectMatch 403 \|
RedirectMatch 403 \.\.
RedirectMatch 403 \%0
RedirectMatch 403 \%A
RedirectMatch 403 \%B
RedirectMatch 403 \%C
RedirectMatch 403 \%D
RedirectMatch 403 \%E
RedirectMatch 403 \%F
RedirectMatch 403 \%22
RedirectMatch 403 \%27
RedirectMatch 403 \%28
RedirectMatch 403 \%29
RedirectMatch 403 \%3C
RedirectMatch 403 \%3E
RedirectMatch 403 \%3F
RedirectMatch 403 \%5B
RedirectMatch 403 \%5C
RedirectMatch 403 \%5D
RedirectMatch 403 \%7B
RedirectMatch 403 \%7C
RedirectMatch 403 \%7D
# COMMON PATTERNS
Redirectmatch 403 \_vpi
RedirectMatch 403 \.inc
Redirectmatch 403 xAou6
Redirectmatch 403 db\_name
Redirectmatch 403 select\(
Redirectmatch 403 convert\(
Redirectmatch 403 \/query\/
RedirectMatch 403 ImpEvData
Redirectmatch 403 \.XMLHTTP
Redirectmatch 403 proxydeny
RedirectMatch 403 function\.
Redirectmatch 403 remoteFile
Redirectmatch 403 servername
Redirectmatch 403 \&rptmode\=
Redirectmatch 403 sys\_cpanel
RedirectMatch 403 db\_connect
RedirectMatch 403 doeditconfig
RedirectMatch 403 check\_proxy
Redirectmatch 403 system\_user
Redirectmatch 403 \/\(null\)\/
Redirectmatch 403 clientrequest
Redirectmatch 403 option\_value
RedirectMatch 403 ref\.outcontrol
# SPECIFIC EXPLOITS
RedirectMatch 403 errors\.
RedirectMatch 403 config\.
RedirectMatch 403 include\.
RedirectMatch 403 display\.
RedirectMatch 403 register\.
Redirectmatch 403 password\.
RedirectMatch 403 maincore\.
RedirectMatch 403 authorize\.
Redirectmatch 403 macromates\.
RedirectMatch 403 head\_auth\.
RedirectMatch 403 submit\_links\.
RedirectMatch 403 change\_action\.
Redirectmatch 403 com\_facileforms\/
RedirectMatch 403 admin\_db\_utilities\.
RedirectMatch 403 admin\.webring\.docs\.
Redirectmatch 403 Table\/Latest\/index\.
</IfModule>
#AIOWPS_ADVANCED_CHAR_STRING_FILTER_END
#AIOWPS_BLOCK_SPAMBOTS_START
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} ^(.*)?wp-comments-post\.php(.*)$
RewriteCond %{HTTP_REFERER} !^http(s)?://example\.net\.au [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule .* http://127.0.0.1 [L]
</IfModule>
#AIOWPS_BLOCK_SPAMBOTS_END
#AIOWPS_PREVENT_IMAGE_HOTLINKS_START
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png)$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://example\.net\.au [NC]
RewriteRule \.(gif|jpe?g?|png)$ - [F,NC,L]
</IfModule>
#AIOWPS_PREVENT_IMAGE_HOTLINKS_END
# END All In One WP Security
最佳答案
问题在于
RewriteRule ^(.*)$ www.example.net/$1 [L,R=301,NC]
www.example.net
被视为相对路径,而不是不同的域。
这就是它将 URL http://example.net/some/path
重写为 http://example.net/www.example.net/some 的原因/path
,再次重写为 http://example.net/www.example.net/www.example.net/some/path
等等。
如果您想从域 example.net
重写到域 www.example.net
,您必须将协议(protocol) (http
) 添加为嗯,例如
RewriteRule ^(.*)$ http://www.example.net/$1 [L,R=301,NC]
批发域名重定向的另一种方法是使用 Redirect
指令
Redirect / http://www.example.net
<小时/>
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ %{HTTP_HOST}/$1 [L,R=301,NC]
使用 %{HTTP_HOST}
具有相同的效果,因为它不包含方案,即 http
或 https
。此外,您从 %{HTTP_HOST}
重写为 %{HTTP_HOST}
,这不会发生任何变化。
要解决此问题,您必须在替换前添加 www.
以及方案(http
或 https
)。这里不需要 NC
标志,因为无论如何您都会查找任何字符 .*
。所以规则应该看起来像
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R]
最后,切勿使用 R=301
进行测试!请参阅此答案 Tips for debugging .htaccess rewrite rules了解详情。
关于wordpress - 尝试使用 htaccess 重定向站点时出现 "Too many redirects",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30205294/
我想知道的区别按照重定向 和 自动重定向 使用 Jmeter 录制时。 当与 一起使用时,这两者会有什么影响?从 HTML 中检索所有嵌入的资源 最佳答案 Redirect automatically
我正在编写一个 WordPress 插件,它添加了一个管理菜单页面。页面中有一个表格。提交表单后,插件将写入数据库。但后来我遇到了一个问题:每当用户重新加载页面时,都会询问他/她是否再次发送 POST
我有两个扩展程序,我想在某个操作中从一个扩展程序重定向到另一个扩展程序。这是我的 bpsmessagecentre 扩展的 bpsmessagecontroller 的 saveAction 中的重定
当我有这个命名路线时:Route::get('/', 'IndexController@index')->name('home'); 然后在任何 Controller 的任何 Action 方法中;当
我正在尝试设置 Lumen - 建立在 Laravel 组件之上的“微框架”。服务器端有 nginx + php-fpm。 这是我的 nginx 配置: server { server_nam
我是ASP.Net 4.0的新手,并且看到了一个名为Response.RedirectPermanent()的新功能。我检查了几篇文章,但是我无法清楚地理解Response.RedirectPerma
我想从路线 /new 重定向,并保留 new 的查询参数路线: 据我所知,唯一可以访问queryParams的地方位于model内路线的钩子(Hook)。 但我想重定向到 beforeModel ho
我在实现简单的HTTP重定向时遇到问题。 我使用Liferay 6.0.6,我们的 portlet 是使用 JSF2.0 /PortletFaces构建的。 我想在加载 View 时(而不是在触发操作
我正在尝试设置 NGINX 和 cloudflare。 我在谷歌上读过这个,但没有解决我的问题 .我的 cloudflare 目前处于事件状态。我删除了 cloudflare 中的所有页面规则,但之前
我有一个运行两个子域的 Nginx 服务器。其中一个使用 proxy_pass 将所有内容重定向到 Meteor 应用程序,另一个子域仅使用 Laravel,但位于与普通域不同的目录中。 因此,当我启
我想在注册后将用户重定向到另一个表单,然后他才能访问我网站上的任何内容(例如 https://github.com/FriendsOfSymfony/FOSUserBundle/issues/387
我有一个提交到详细信息页面的表单,其中有一个按钮。我在我的映射文件中放置了一个 Action 以将一个 Action 链接到该按钮,该按钮应将用户发送回表单并将其清空。 我可以正确地重定向它,但表单仍
我一直在谷歌上搜索这个,但似乎没有人知道答案。 这篇文章很好地描述了这个问题: http://www.mail-archive.com/php-general@lists.php.net/msg198
在 Sinatra 中使用 redirect 和 redirect to 有什么区别?他们似乎都默认为相同的状态代码。 to '/url' 位是否只是为了使方法更具可读性的一些语法上的好处? 最佳答案
这是一个可以抛出异常的示例按钮: 在我的 ExceptionHandler我有: FacesContext.getCurrentInstance().getExternalContext
我现在在同一家公司的多个网站上工作,每个网站都通过顶部标题上的链接列表连接到其他网站。 访问跟踪是通过谷歌分析完成的,一切似乎都运行良好。太糟糕了,他们现在似乎对附加在 url 底部以获得跨域跟踪的所
目前我正在开发一个项目,该项目在提交时对表单执行一些客户端验证(使用 Javascript),然后基于 Ajax 请求,或者进行 window.location.href 重定向或提交表单以供 Con
我将我的 Gitlab 迁移到了新域。我想将所有 HTTP 请求从旧 URL 重定向到新 URL。两个域当前都指向同一服务器(使用 A DNS 记录)。 我使用 Gitlab Omnibus 包,并捆
我想在每个以“/”结尾的文档中添加“.html”,但主页除外。 我尝试了一些不同的方法,使用 nginx 重写和返回 301,但我没有让它工作。附上我做的最后一个版本,它正在做/*/.html 但第二
我想在每个以“/”结尾的文档中添加“.html”,但主页除外。 我尝试了一些不同的方法,使用 nginx 重写和返回 301,但我没有让它工作。附上我做的最后一个版本,它正在做/*/.html 但第二
我是一名优秀的程序员,十分优秀!