简体   繁体   English

重定向到 www。 没有丢失的变量得到

[英]redirect to www. without lost variables get

I am redirecting via .htaccess so that when they enter my domain.com site it will take them to www.domain.com .我通过 .htaccess 重定向,这样当他们进入我的 domain.com 站点时,它会将他们带到www.domain.com This works fine, but when the url contains some get variable it gets lost.这很好用,但是当 url 包含一些 get 变量时,它会丢失。

Example: Entering domain.com/archive.php?var=something.示例:输入 domain.com/archive.php?var=something。

I get redirected to www.domain.com/archive.php Losing the get variable var=something...我被重定向到www.domain.com/archive.php丢失获取变量 var=something...

In my htaccess I have the following:在我的 htaccess 中,我有以下内容:

RewriteRule (.) http://www.example.com/$1 [R=301,L]

#redirigir index.html e index.php a raiz
RewriteCond %{REQUEST_URI} ^/index.php
RewriteRule ^.$ http://%{HTTP_HOST} [R=301,L]
RewriteCond %{REQUEST_URI} ^/index.html
RewriteRule ^.*$ http://%{HTTP_HOST} [R=301,L]

What am I doing wrong?我究竟做错了什么?

Hey i think this can work for you嘿,我认为这对你有用

Options +FollowSymlinks -MultiViews
RewriteEngine on

# for http
RewriteCond %{HTTP_HOST} ^(www\.)?domainA\.com$ [NC]
RewriteCond %{SERVER_PORT} =80
RewriteRule ^(.*)$ http://www.domainB.com/$1 [R=301,L]

# for https
RewriteCond %{HTTP_HOST} ^(www\.)?domainA\.com$ [NC]
RewriteCond %{SERVER_PORT} =443
RewriteRule ^(.*)$ https://www.domainB.com/$1 [R=301,L]

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

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