Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.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
Php .htaccess重写域&;保留路径_Php_Regex_.htaccess_Mod Rewrite - Fatal编程技术网

Php .htaccess重写域&;保留路径

Php .htaccess重写域&;保留路径,php,regex,.htaccess,mod-rewrite,Php,Regex,.htaccess,Mod Rewrite,有人能帮我重写域名但保留路径吗?我似乎找不到我要找的东西,找到了很多关于重定向的文章,但没有重写 www.domain2.com/path1/page.html as www.domain1.com/path1/page.html www.domain2.com/path1/page.html as www.domain1.com/path1/page.html 我有很多域名 非常感谢您的建议或链接到一篇有答案的文章 Stu下面的。htaccess代码就可以了 RewriteEngine On

有人能帮我重写域名但保留路径吗?我似乎找不到我要找的东西,找到了很多关于重定向的文章,但没有重写

www.domain2.com/path1/page.html as www.domain1.com/path1/page.html
www.domain2.com/path1/page.html as www.domain1.com/path1/page.html
我有很多域名

非常感谢您的建议或链接到一篇有答案的文章


Stu

下面的
。htaccess
代码就可以了

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !domain1.com$ [NC]
RewriteRule ^(.*)$ http://www.domain2.com/$1 [L,R=301]
对于重写和重定向之间的区别来说,它是非常小的。第一个是不明确的位置重定向(用户不会在浏览器地址栏中看到),第二个是完全重定向


要将非SSL重写为SSL,请将url前缀从
http
更改为
https
,并确保您拥有有效的SSL证书。

实际上,如果您能够解释重定向与重写之间的关系,这可能是很好的了解。您还可以将非ssl重写为ssl吗?所有域名是否都指向同一台服务器?同一台服务器的多存储magento安装可能重复。