Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex HttAccess从http重定向到https并获取参数_Regex_.htaccess_Mod Rewrite - Fatal编程技术网

Regex HttAccess从http重定向到https并获取参数

Regex HttAccess从http重定向到https并获取参数,regex,.htaccess,mod-rewrite,Regex,.htaccess,Mod Rewrite,我需要重定向这个: 对此 到目前为止,我所拥有的是: RewriteRule ^/pages/addtocart.php?(.*)$ https://www.mysite.com/checkout/cart/addsku?$1 [R=301,L] 但它不起作用。 帮助?通过httpd.conf启用mod\u rewrite和.htaccess,然后将此代码放入您的文档根目录/.htaccess文件: Options +FollowSymLinks -MultiViews # Turn mo

我需要重定向这个:

对此

到目前为止,我所拥有的是:

RewriteRule ^/pages/addtocart.php?(.*)$ https://www.mysite.com/checkout/cart/addsku?$1 [R=301,L]
但它不起作用。
帮助?

通过
httpd.conf
启用
mod\u rewrite
.htaccess
,然后将此代码放入您的
文档根目录/.htaccess
文件:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} off
RewriteRule ^pages/addtocart\.php$ https://%{HTTP_HOST}/checkout/cart/addsku [L,R=302,NC]
PS:查询参数将自动带入新URL