简体   繁体   English

htaccess使用参数重定向到新域

[英]htaccess redirect to new domain with parameters

I need to redirect from abc.com/param to test.bcd.com/?query=param via htaccess. 我需要通过htaccess从abc.com/param重定向到test.bcd.com/?query=param

Is it correct? 这是正确的吗?

RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www\.)?test\.bcd\.com$ [NC]
RewriteRule .* http://test.bcd.com/?query=%{REQUEST_URI} [R=301,L]

Please try this 请尝试这个

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]

for redirect to index.html then try this 重定向到index.html,然后尝试这个

Please add following two lines to allow a specific file to load just in case there is no default index file setup already 请添加以下两行以允许加载特定文件,以防万一尚未设置默认索引文件

Options -Indexes
DirectoryIndex index.html index.php

Note : if you have to load first php index file then you have set like 注意:如果必须先加载php索引文件,则需要设置如下

DirectoryIndex index.php index.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM