.htaccess正被本地主机使用 [英] .htaccess is being forefully used for localhost
问题描述
我在本地主机上使用wamp-server并命名为www.xyz.com
的虚拟主机,我通过git设置了部署服务,该部署服务将代码部署到www.xyz.in
I am using wamp-server as on localhost with a virtual host named www.xyz.com
i have a deployment service set through git which deploys code to server on www.xyz.in
这是我的.htaccess代码
This is my .htaccess code
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
前缀
The above code will make your domain to add https
prefix
此代码的问题在于,在server
上,该代码在localhost
上可以完美运行,而且与https:// www.xyz.com
一样,但是在localhost
上没有这样的https
东西.因此,对此代码有什么解决方案,应该避免将https
作为前缀放在localhost
上,并像在online server
上那样工作.
The problem with this code is that on server
the code works perfect bu on localhost
also it works like https:// www.xyz.com
, but on localhost
there is no such https
thing. So is there any solution to this code that it should avoid putting https
as a prefix on localhost
and work as it is on online server
.
我期望上面的代码有类似的东西:
I am expecting something like this from the above code:
1.)如果我在本地主机(www.xyz.com)上调用URL,则应为(www.xyz.com
)
1.) If I call the URL on localhost (www.xyz.com) - It should be as it is like (www.xyz.com
)
2.)如果我在服务器(www.xyz.in
或xyz.in
)上调用URL-应该像(https://www.xyz.in
)
2.) If I call URL on server (www.xyz.in
or xyz.in
) - It should be like (https://www.xyz.in
)
任何帮助表示赞赏.
推荐答案
在RewriteEngine on
之后添加此内容:
RewriteCond %{HTTP_HOST} !=localhost
这篇关于.htaccess正被本地主机使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!