apache - htaccess 使用参数重定向到新域
问题描述
我需要通过 htaccess重定向abc.com/param
到。test.bcd.com/?query=param
这是对的吗?
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www\.)?test\.bcd\.com$ [NC]
RewriteRule .* http://test.bcd.com/?query=%{REQUEST_URI} [R=301,L]
解决方案
请试试这个
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteCond %{QUERY_STRING} ^query=param [NC]
RewriteCond %{HTTP_HOST} !^(www\.)?test\.bcd\.com$ [NC]
RewriteRule ^ http://test.bcd.com%{REQUEST_URI}?%{QUERY_STRING} [R=301,L]
重定向到 index.html 然后试试这个
请添加以下两行以允许加载特定文件,以防万一还没有默认索引文件设置
Options -Indexes
DirectoryIndex index.html index.php
注意:如果你必须加载第一个 php 索引文件,那么你已经设置为
DirectoryIndex index.php index.html
推荐阅读
- reactjs - 如何修复错误:对象作为 React 子对象无效(找到:带有键 {} 的对象)
- python - 如何在 Python 中对以下编码场景进行编码?
- javascript - 如何使用正则表达式提取没有路径参数或查询参数的 url 的相对路径?
- visual-studio-code - VSCode 在 OS 更新后以黑底灰显示代码
- pyspark - 如何将字符串附加到pyspark中列出的数据框列
- python - 无法加载请求的 DLL 找不到指定的模块
- assembly - 反向字符串 MASM
- c++ - 如何在 C++ 中将空格分隔的输入插入数组
- linux - 如果我将浮点数除以零,为什么会引发“浮点异常”?
- python - 如何在matplotlib中向相反方向(向下)添加第三个y轴?