如何使用htaccess将www和非www重定向到特定域的https(how to redirect www and non www to https for specific domain using htaccess)
我需要将www和非www重定向到https。 我已经在stackoverflow上到处寻找,但找不到我正在寻找的东西。
规则是:
- example.com和www.example.com以及https://example.com必须重定向到https://www.example.com
- 它必须与域和扩展example.com匹配。 它不能是一张外卡,它也匹配abc.com或123.com或example.net或其他任何东西
- 它必须仅匹配www子域。 它不能是与sub.example.com或thisisademo.example.com匹配的外卡
我目前有:
RewriteCond %{HTTP_HOST} ^example.com$ RewriteRule (.*) https://www.example.com/$1 [R=301,L]
但是,如果有人进入www.example.com,它仍会转到http版本而不是https。
我认为我真正需要的是RewriteCond正则表达式以完全匹配,只有“example.com”和“www.example.com”
谢谢
I need to redirect www and non www to https. I have looked everywhere on stackoverflow but can't find quite what I'm looking for.
The rules are:
- example.com and www.example.com and https://example.com must redirect to https://www.example.com
- It must match the domain and extension example.com. It cannot be a wild card which also matches abc.com or 123.com or example.net or anything else
- It must match for www subdomains only. It cannot be a wild card which also matches sub.example.com or thisisademo.example.com
I currently have:
RewriteCond %{HTTP_HOST} ^example.com$ RewriteRule (.*) https://www.example.com/$1 [R=301,L]
However if someone enters www.example.com it still goes to the http version instead of https.
What I think I actually need here is RewriteCond regex to match exactly and only "example.com" and "www.example.com"
Thanks
原文:https://stackoverflow.com/questions/37109618
最满意答案
添加这个依赖
<dependency> <groupId>org.glassfish.jersey.media</groupId> <artifactId>jersey-media-json-jackson</artifactId> </dependency>
add this dependecy
<dependency> <groupId>org.glassfish.jersey.media</groupId> <artifactId>jersey-media-json-jackson</artifactId> </dependency>
相关问答
更多-
尝试一下: @RequestMapping(method = RequestMethod.POST,consumes = {"application/json;charset=UTF-8"}, produces={"application/json;charset=UTF-8"}) public String newPlace(@RequestBody Place places) { String id = service.addNewPlace(places); return "/ad ...
-
不知道原因,但是从con.setRequestProperty("Content-Type", "application/json; charset=utf8")删除线charset=utf8解决了这个问题。 Not sure about the reason but Removing lines charset=utf8 from con.setRequestProperty("Content-Type", "application/json; charset=utf8") resolved the is ...
-
HTTP 406和415错误代码(HTTP 406 and 415 error codes)[2022-06-26]
406由服务器返回,当它不能基于接受请求头(即它们有一个Accept标头,它们声明他们只想要XML)进行响应时。 当请求中发送的实体(POST或PUT中的内容)具有不受支持的媒体类型(即,它们发送XML)时,服务器返回415。 所以.. 406当你不能发送他们想要什么,415当他们发送你不想要的。 希望有帮助! 406 is returned by the server when it can't respond based on accepting the request headers (ie they ... -
您可以创建消息处理程序,它将在管道中提前检查请求的内容类型,如果不支持请求内容类型,则返回415空状态的状态代码: public class UnsupportedContentTypeHandler : DelegatingHandler { private readonly MediaTypeHeaderValue[] supportedContentTypes = { new MediaTypeHeaderValue("application/json") }; ...
-
错误代码415与改造(Error Code 415 with retrofit)[2023-10-19]
要发送json有效内容,请定义一个包装类 - data class EmailBody(val email: String) 并将其用作POST的@Body @POST("v1/User/forgot-password") fun forgotPass(@Body email: EmailBody): Call然后,当您想要调用它时,请将电子邮件地址封装在EmailBody对象中 - service.forgotPass(EmailBody(email)) To send a json ... -
通过nodejs状态代码错误415调用Web服务(Soap)(Invoking Web Service(Soap) through nodejs Status Code error 415)[2023-10-15]
该死的...它的愚蠢的错误,它应该是标题,'错过了'。 var options = { host:'localhost', port:'34563', path:'/Service1.svc', connection:'keep-alive', accept:'*/*', method:'POST', headers: { 'Content-Type':'text/xml;charset="UTF-8"', 'Content-Length':dat ... -
添加这个依赖
org.glassfish.jersey.media jersey-media-json-jackson org.glassfish.jersey.media jersey-media-json- ... -
感谢@Wain评论,我通过创建请求并设置内容类型标题解决了问题: NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:url]; [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [request setHTTPMethod:@"POST"]; [request setHTTPBody:jsonData]; R ...
-
JSON API定义客户端必须发送Content-Type: application/vnd.api+json Answering my own question based on the comments (thanks @chetan-ranpariya) You don't need to pass a Content-type on GET requests the API should ignore the header; issue has been reported to API team
-
这个提议: http://tools.ietf.org/html/draft-wilde-accept-post-02 可能有趣。 This proposal: http://tools.ietf.org/html/draft-wilde-accept-post-02 might be of interest.