apache - 使用 htaccess 重写规则
问题描述
我想在不同的 URL 中重定向以下 URL。请帮助我。
第一个网址:
http://localhost/magento2-ce/images/ 重定向到 http://localhost/magento2-ce/
第二个网址:
http://localhost/magento2-ce/images/9781601525871/ 重定向到 http://localhost/magento2-ce//book/landing/detailedview?itemcode=9781601525871J
我做了什么?
我尝试了以下解决方案以使第二个 URL 正常工作。
RewriteRule ^images/([0-9]+)/ http://localhost/magento2-ce/book/landing/detailedview?itemcode=$1J [R=301,NC,L]
但是,当我将以下规则应用于第一个 URL 重定向时,上面的重写规则不起作用。
RewriteRule ^images/ http://localhost/magento2-ce/ [R=301,NC,L]
解决方案
您是否尝试过从一个或两个规则中删除 L(最后一个)标志? https://httpd.apache.org/docs/2.4/rewrite/flags.html
推荐阅读
- android - 图像的可点击区域(鼠标悬停事件) - Jetpack Compose Desktop
- amazon-web-services - 使用无服务器框架部署 AWS Lambda 时缺少依赖项
- vue.js - Google 跟踪代码管理器分析选项无法正常工作
- html - 为什么页面加载时我的引导选项卡不显示?
- javascript - Javascript通过按键旋转播放器
- java - 在 Cloud Foundry 上使用 Tabula-py 时未找到 Java
- ruby-on-rails - 回形针上传/更新:Rails 6 上无法修改冻结字符串:“”错误
- javascript - 为什么这个 Jest 测试没有失败?
- sql - 根据另一个字段自动生成数字字段
- php - 当字符串小于 PHP 8 中的起始字符时 substr 返回一个空字符串