Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.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/8/.htaccess/6.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一直用于localhost_Php_.htaccess_Server_Localhost_Wamp - Fatal编程技术网

Php .htaccess一直用于localhost

Php .htaccess一直用于localhost,php,.htaccess,server,localhost,wamp,Php,.htaccess,Server,Localhost,Wamp,我在本地主机上使用wamp server as,虚拟主机名为www.xyz.com我通过git设置了一个部署服务,它将代码部署到www.xyz.in 这是我的.htaccess代码 RewriteEngine on RewriteCond %{HTTP_HOST} !^www\. [NC,OR] RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC] RewriteRule ^ https://www.%1%

我在本地主机上使用wamp server as,虚拟主机名为
www.xyz.com
我通过git设置了一个部署服务,它将代码部署到
www.xyz.in

这是我的.htaccess代码

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L,NE]
上述代码将使您的域添加
https
前缀

此代码的问题在于,在
服务器上
该代码在
本地主机上
也可以像
https://www.xyz.com
一样工作,但在
本地主机上
没有这样的
https
功能。因此,是否有任何解决方案可以避免将
https
作为前缀放在
localhost
上,并像在
在线服务器上一样工作

我期望从上述代码中得到类似的结果:

1.)如果我调用localhost(www.xyz.com)上的URL,它应该是这样的(
www.xyz.com

2.)如果我调用服务器上的URL(
www.xyz.in
xyz.in
),它应该像(
https://www.xyz.in


感谢您的帮助。

上重写引擎后添加此项:

RewriteCond %{HTTP_HOST} !=localhost

所以,只需添加另一个条件,检查主机名是否为localhost。实际上,我只是一个noob to。htaccess rules您能帮我修改代码吗?然后简单的方法是注释掉https行,并使用http或local@GauravRai你能提供修改后的代码吗?@miken32你能帮我修改一下代码吗?