.htaccess正被本地主机使用 [英] .htaccess is being forefully used for localhost

查看:75
本文介绍了.htaccess正被本地主机使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地主机上使用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.inxyz.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆