apache - .htaccess 问题重定向 301 -
问题描述
我们已经重组了我们的网站并尝试实施 Redirect 301,但无济于事。看起来很简单,但是页面不会重定向,当我们验证示例 URL 时,状态 200 仍然显示在原始页面上。
这是我们正在使用的代码:
AddHandler server-parsed .htm .html
DirectoryIndex index.jsp index.htm /index.jsp
RewriteEngine On
# Redirect to preferred www example
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) https://example.com/$1 [R=301,L]
Redirect 301 /products/manufacturer_1.jsp https://www.example.com/brands/manufacturer_1.jsp
HTTP 到 HTTPS 重写工作正常,但重定向 301 不能。没有其他重写或重定向,所以不应该有任何冲突。
任何建议都会有所帮助,并提前感谢您的帮助。
最好的,马修
解决方案
因为我们使用的是 JSP 页面。.htaccess 中的重定向 301 从未被处理。因此,我们必须在我们的页面上嵌入以下代码:
<%
response.setStatus(301);
response.setHeader( "Location", modelUrlString );
response.setHeader( "Connection", "close" );
%>
推荐阅读
- r - 根据现有列计算数据框中的新累积列
- oracle - Oracle PLSQL - 带有通配符的多个 LIKE 标准
- python - 为什么正则表达式不能正常替换文本
- linux - 给Linux当前目录下的所有子目录添加后缀
- sql - Group by 和 order By 一起导致错误
- sql - 重定位文件后 SQL Server 恢复数据库
- php - 我在 init.php 文件中定义了一个变量(VOTING_ALLOWED),但我没有在其他页面中获得值
- sql-server - 如何在 SQL Server 扩展事件中单独跟踪游标语句?
- python-3.x - PyCharm Git VCS Grays Out 添加选项
- html - 制作简单的汉堡菜单